Boost Users :
Subject: Re: [Boost-users] Signals2 benchmark
From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2015-02-06 13:41:17
On Fri, Feb 6, 2015 at 1:06 PM, Bjorn Reese <breese_at_[hidden]> wrote:
> On 02/06/2015 06:45 PM, Joren Heit wrote:
>> One thing I don't quite grasp yet, is the following. Suppose one thread
>> disconnects a slot while another fires a signal connected to that slot.
>> You say that the implementation must make sure that the signal is not
>> fired after the disconnect-call returns. But won't this be undefined
>> behaviour, as there is no way of knowing which will grab the lock first?
> 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.
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
> Boost-users mailing list
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net