Fix to an issue causing a thread to exit if any fiber therein self-cancels
This commit is contained in:
parent
8468f392ce
commit
9e75d47ba3
4 changed files with 10 additions and 6 deletions
|
|
@ -78,9 +78,10 @@ namespace fc {
|
|||
|
||||
std::unordered_map<std::string,logger>& get_logger_map() {
|
||||
static bool force_link_default_config = fc::do_default_config;
|
||||
static std::unordered_map<std::string,logger> lm;
|
||||
//TODO: Atomic compare/swap set
|
||||
static std::unordered_map<std::string,logger>* lm = new std::unordered_map<std::string, logger>();
|
||||
(void)force_link_default_config; // hide warning;
|
||||
return lm;
|
||||
return *lm;
|
||||
}
|
||||
|
||||
logger logger::get( const fc::string& s ) {
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ namespace fc {
|
|||
}
|
||||
|
||||
void promise_base::cancel(){
|
||||
// wlog("${desc} canceled!", ("desc", _desc? _desc : ""));
|
||||
_canceled = true;
|
||||
}
|
||||
bool promise_base::ready()const {
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ namespace fc {
|
|||
return;
|
||||
}
|
||||
|
||||
//wlog( "${s}", ("s",name()) );
|
||||
// wlog( "${s}", ("s",name()) );
|
||||
// We are quiting from our own thread...
|
||||
|
||||
// break all promises, thread quit!
|
||||
|
|
@ -200,9 +200,9 @@ namespace fc {
|
|||
try {
|
||||
my->process_tasks();
|
||||
}
|
||||
catch( canceled_exception& )
|
||||
catch( canceled_exception& e )
|
||||
{
|
||||
wlog( "thread canceled" );
|
||||
wlog( "thread canceled: ${e}", ("e", e.to_detail_string()) );
|
||||
}
|
||||
delete my->current;
|
||||
my->current = 0;
|
||||
|
|
|
|||
|
|
@ -345,8 +345,10 @@ namespace fc {
|
|||
//current = prev;
|
||||
}
|
||||
|
||||
if( current->canceled )
|
||||
if( current->canceled ) {
|
||||
current->canceled = false;
|
||||
FC_THROW_EXCEPTION( canceled_exception, "" );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue