Boost logo

Boost Users :

Subject: Re: [Boost-users] Mixing signals2 and asio mechanism failing
From: ustulation (ustulation_at_[hidden])
Date: 2013-10-20 03:37:30

:) I feel somewhat intimidated talking to developers of world-renowned
libraries themselves - what might be difficult for me might be so trivial
for you; but anyway here's the question - So since the things are the way
they are how do I achieve a thread safe clean-up? This is what it is:

{ io_service::run is called by many threads and classes use
enable_shared_from_this idiom }

class A
/* has signals2::signal(s) for callbacks, fired when completion-handler of
various async operations are invoked (eg., async_read_until etc) */

class B
void registerListenersWith_A()
        /* has member-function listeners submitted to signals of class A eg., auto
self = shared_from_this();
shared_ptr_A->someSig_A.connect([self]{self->mem_func_B();}); */
void disconnectListenersWith_A()
               /* disconnect all boost::signals2::connection(s) made above */

auto shared_ptr_A = std::make_shared< A >();
auto shared_ptr_B = std::make_shared< B >();
give shared_ptr_B a copy of shared_ptr_A for use above.
//....some operations here.....
} //i want pointer managed by shared_ptr_B to be destroyed here in a
thread-safe manner (ie., no pending calls remain from A to B etc.

View this message in context:
Sent from the Boost - Users mailing list archive at

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at