Boost Users :
Subject: Re: [Boost-users] Signals2 benchmark
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2015-02-06 14:18:04
On 6 Feb 2015 at 18:45, Joren Heit 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?
An atomic increment/decrement use count maybe? Slow when contended,
but faster possibly than alternatives.
BTW you can fold a lock into a pointer by using its bottom bit as the
lock bit. I have an implementation in Boost.Spinlock if you want it.
-- ned Productions Limited Consulting http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/
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