fix thread quit

This commit is contained in:
Daniel Larimer 2012-09-10 23:19:18 -04:00
parent 90f9a1f04d
commit ad164f576e
2 changed files with 7 additions and 1 deletions

View file

@ -34,6 +34,8 @@ namespace fc {
elog( "Caught unhandled exception" ); elog( "Caught unhandled exception" );
} }
slog( "exiting %s", name ); slog( "exiting %s", name );
delete this->my;
slog( "..." );
} ); } );
p->wait(); p->wait();
my->boost_thread = t; my->boost_thread = t;
@ -71,9 +73,12 @@ namespace fc {
void thread::quit() { void thread::quit() {
if( &current() != this ) { if( &current() != this ) {
wlog( "async quit %s", my->name.c_str() ); wlog( "async quit %s", my->name.c_str() );
async( [=](){quit();} ).wait(); async( [=](){quit();} );//.wait();
if( my->boost_thread ) { if( my->boost_thread ) {
auto n = name();
slog( "joining... %s", n.c_str() );
my->boost_thread->join(); my->boost_thread->join();
slog( "done joining... %s", n.c_str() );
} }
return; return;
} }

View file

@ -321,6 +321,7 @@ namespace fc {
if( done ) return; if( done ) return;
if( timeout_time == time_point::max() ) { if( timeout_time == time_point::max() ) {
slog("wait");
task_ready.wait( lock ); task_ready.wait( lock );
} else if( timeout_time != time_point::min() ) { } else if( timeout_time != time_point::min() ) {
slog("timed wait"); slog("timed wait");