diff --git a/src/thread_local_queue.cpp b/src/thread_local_queue.cpp index 44572b3..c975532 100644 --- a/src/thread_local_queue.cpp +++ b/src/thread_local_queue.cpp @@ -243,21 +243,21 @@ namespace boost { namespace synapse { for( unsigned serial_number=last_poll_serial_number; serial_number!=current; ++serial_number ) { bool found = std::find_if( same_thread_different_signals_.begin(), same_thread_different_signals_.end(), - [&count,serial_number]( cl_rec const & r ) + [&count,serial_number]( cl_rec const & r ) + { + if( shared_ptr sp=r.lock() ) { - if( shared_ptr sp=r.lock() ) + int n=sp->ps_->emit_if_serial_number_matches(serial_number,*sp); + if( n>=0 ) { - int n=sp->ps_->emit_if_serial_number_matches(serial_number,*sp); - if( n>=0 ) - { - count+=n; - return true; - } - else - BOOST_SYNAPSE_ASSERT(n==-1); + count+=n; + return true; } - return false; - } )!=same_thread_different_signals_.end(); + else + BOOST_SYNAPSE_ASSERT(n==-1); + } + return false; + } )!=same_thread_different_signals_.end(); BOOST_SYNAPSE_ASSERT(found); } return count; @@ -314,20 +314,12 @@ namespace boost { namespace synapse { std::thread::id const tid_; shared_ptr const tlcll_; - shared_ptr const conn_bare_lambda_; - - static void call_bare_lambda( function const & f ) - { - BOOST_SYNAPSE_ASSERT(f); - f(); - } public: thread_local_queue(): tid_(std::this_thread::get_id()), - tlcll_(synapse_detail::get_thread_local_connection_list_list()), - conn_bare_lambda_(connect(this,&call_bare_lambda)) + tlcll_(synapse_detail::get_thread_local_connection_list_list()) { tlcll_->enable_tlq(); } @@ -358,7 +350,13 @@ namespace boost { namespace synapse { shared_ptr create_thread_local_queue() { - return make_shared(); + std::shared_ptr tlq = make_shared(); + (void) connect(tlq, []( std::function const & f ) + { + BOOST_SYNAPSE_ASSERT(f); + f(); + } ); + return tlq; } int poll( thread_local_queue & tlq )