Boost logo

Boost :

From: Andreas Huber (ah2003_at_[hidden])
Date: 2004-03-10 08:42:29

David Turner <dkturner <at>> writes:

> Hi
> > I was checking out if I could use Boost to port code written
> > for Windows to Unix.
> >
> > The code has calls to WaitForMultipleObject which I would
> > need to replace.
> You can always do the same thing by means of conditions and signals. The
> paradigm is slightly different, though.
> //...
> boost::condition cond;
> object1.signal.connect(boost::bind(&boost::condition::notify_all, &cond));
> object2.signal.connect(boost::bind(&boost::condition::notify_all, &cond));
> cond.wait(mutex_lock);
> //...

>From the current signals FAQ:
2. Is Boost.Signals thread-safe?
 No. Using Boost.Signals in a multithreaded concept is very dangerous, and it
is very likely that the results will be less than satisfying. Boost.Signals
will support thread safety in the future.

I see that what you describe *can* be MT-safe nevertheless but only if you pay
a lot of attention to the details, i.e. object1.signal.connect() must not be
called while another thread could simultaneously call object1.signal(). This
can often not be guaranteed and users would therefore have to protect the
signal manually.



Boost list run by bdawes at, gregod at, cpdaniel at, john at