Boost logo

Boost Users :

Subject: Re: [Boost-users] Signals2 benchmark
From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2015-02-06 13:38:33


On Fri, Feb 6, 2015 at 12:45 PM, Joren Heit <jorenheit_at_[hidden]> wrote:
> Thanks Tony for the thorough reply. I had just made sure that signals can be
> (dis)connected by multiple threads in a thread-safe manner, but you are
> right that there is much more to it. This will be hard to implement I think,
> but I'll do my best!
>
> 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?
>
> Joren
>

Yes either can grab the lock first. And then you need to do the right
thing in either case.
If the disconnect grabs the lock first, the signal-firing, once it
obtains the lock, can't call the slot. ie either the slot is gone or
has been marked null/disconnected/something.
If the signal-firing grabs the lock first, no problem.


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