clean up prints
This commit is contained in:
parent
ad164f576e
commit
ac7ca49af5
3 changed files with 3 additions and 11 deletions
|
|
@ -22,8 +22,7 @@ namespace fc {
|
||||||
|
|
||||||
inline void wait( boost::signal<void()>& sig, const microseconds& timeout_us=microseconds::max() ) {
|
inline void wait( boost::signal<void()>& sig, const microseconds& timeout_us=microseconds::max() ) {
|
||||||
promise<void>::ptr p(new promise<void>());
|
promise<void>::ptr p(new promise<void>());
|
||||||
boost::signals::scoped_connection c = sig.connect( [=]() { slog( "set value!" );p->set_value(); } );
|
boost::signals::scoped_connection c = sig.connect( [=]() { p->set_value(); } );
|
||||||
slog( "wait quit" );
|
|
||||||
p->wait( timeout_us );
|
p->wait( timeout_us );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,11 +31,10 @@ namespace fc {
|
||||||
p->set_value();
|
p->set_value();
|
||||||
exec();
|
exec();
|
||||||
} catch ( ... ) {
|
} catch ( ... ) {
|
||||||
elog( "Caught unhandled exception" );
|
elog( "Caught unhandled exception %1%", boost::current_exception_diagnostic_information() );
|
||||||
}
|
}
|
||||||
slog( "exiting %s", name );
|
|
||||||
delete this->my;
|
delete this->my;
|
||||||
slog( "..." );
|
this->my = 0;
|
||||||
} );
|
} );
|
||||||
p->wait();
|
p->wait();
|
||||||
my->boost_thread = t;
|
my->boost_thread = t;
|
||||||
|
|
@ -72,7 +71,6 @@ namespace fc {
|
||||||
|
|
||||||
void thread::quit() {
|
void thread::quit() {
|
||||||
if( ¤t() != this ) {
|
if( ¤t() != this ) {
|
||||||
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();
|
auto n = name();
|
||||||
|
|
@ -218,12 +216,10 @@ namespace fc {
|
||||||
|
|
||||||
void thread::poke() {
|
void thread::poke() {
|
||||||
boost::unique_lock<boost::mutex> lock(my->task_ready_mutex);
|
boost::unique_lock<boost::mutex> lock(my->task_ready_mutex);
|
||||||
slog("notify one");
|
|
||||||
my->task_ready.notify_one();
|
my->task_ready.notify_one();
|
||||||
}
|
}
|
||||||
|
|
||||||
void thread::async_task( task_base* t, const priority& p, const time_point& tp, const char* desc ) {
|
void thread::async_task( task_base* t, const priority& p, const time_point& tp, const char* desc ) {
|
||||||
slog( "%s", name().c_str() );
|
|
||||||
task_base* stale_head = my->task_in_queue.load(boost::memory_order_relaxed);
|
task_base* stale_head = my->task_in_queue.load(boost::memory_order_relaxed);
|
||||||
do { t->_next = stale_head;
|
do { t->_next = stale_head;
|
||||||
}while( !my->task_in_queue.compare_exchange_weak( stale_head, t, boost::memory_order_release ) );
|
}while( !my->task_in_queue.compare_exchange_weak( stale_head, t, boost::memory_order_release ) );
|
||||||
|
|
@ -233,7 +229,6 @@ namespace fc {
|
||||||
// when *this thread is about to block on a wait condition.
|
// when *this thread is about to block on a wait condition.
|
||||||
if( this != ¤t() && !stale_head ) {
|
if( this != ¤t() && !stale_head ) {
|
||||||
boost::unique_lock<boost::mutex> lock(my->task_ready_mutex);
|
boost::unique_lock<boost::mutex> lock(my->task_ready_mutex);
|
||||||
slog("notify one");
|
|
||||||
my->task_ready.notify_one();
|
my->task_ready.notify_one();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -321,10 +321,8 @@ 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");
|
|
||||||
task_ready.wait_until( lock, boost::chrono::system_clock::time_point() +
|
task_ready.wait_until( lock, boost::chrono::system_clock::time_point() +
|
||||||
boost::chrono::microseconds(timeout_time.time_since_epoch().count()) );
|
boost::chrono::microseconds(timeout_time.time_since_epoch().count()) );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue