Thanks for the many responses and suggestions. However, I'm not sure if
everything applies to my particular application. If it does, I don't think
I fully understand...
My implementation provides an Emitter class (template), rather than a
signal class. Signals are types which act as template parameters to the
Emitter. For example:
using Event1 = Signal
On Fri, Feb 6, 2015 at 2:23 PM, Niall Douglas
wrote: On 6 Feb 2015 at 13:41, Gottlob Frege wrote:
The easiest solution would be to store the slot as a shared_ptr, and make a copy of it (pin it) each time you call the slot.
So
Thread 1: call signal,... copy slot shared_ptr,... Thread 2: disconnect, clean up resources, set global ptrUsedBySlot = null (since it is no longer used, right?) Thread 1: call slot Thread 1: crash on null ptrUsedBySlot
shared_ptr provides some atomic_exchange overloads. You could atomically swap a slot being deleted with an empty but valid slot type which calls nothing.
That would work to track the "winner". But if the disconnect thread comes in second, it still needs to wait for the slot thread to finish. So you still need a waitable synchronization object of some kind. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users