Boost logo

Boost :

Subject: [boost] [Signals2] Using dummy_mutex in a multithreaded program
From: Peter Petrov (ppetrov_at_[hidden])
Date: 2010-01-18 10:18:22


Greetings Frank, boosters,

Currently using a signal with a boost::signals2:dummy_mutex works well only
in single-threaded programs. I'm wondering if it can be made a little more
useful.

I have an use case with a single global signal, where all slots and
connections are setup on program start. Afterwards a bunch of threads are
fired, and each of them can call the signal's operator(). There are no more
connections added/removed, only signal invocations. According to the
workflow described here:

http://www.boost.org/doc/libs/1_41_0/doc/html/signals2/thread-safety.html#id1695794

...it seems that a dummy_mutex should be enough, since the slot list is
never modified. It turns out it's not - I'm getting assertion failures
in nolock_cleanup_connections() because the _shared_state.unique()
requirement is sometimes violated.

Because using a real mutex will significantly degrade both performance and
concurrency, I'm wondering if this assertion is really necessary. In this
case it should be safe to continue even if the uniqueness is violated,
because the connection list is never modified. And I think my use case is
quite common :)

- Peter


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk