$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2007-06-18 15:48:59
Zeljko Vrba wrote:
> On Mon, Jun 18, 2007 at 10:48:14AM -0500, Graham Reitz wrote:
>> Is there a method  to release all threads waiting on a mutex?  Or, more
>> generally, a portable way to release a bunch of threads at the same time?
>> (boost::asio?)
>>
>> I didn't see anything in the docs, besides barrier.  Unfortunately, I can't
>> guarantee the N threads will be waiting when a flush is needed.
>>
> 
> You want a SYSV-style semaphore (semget/semop/semctl in POSIX; seems not to
> be provided by Boost.Thread).  
Not necessarily. It depends on whether we want a thread that reaches the 
synchronization point after the "go" to pass (as when downing a 
semaphore) or to stop (as with a missed condition notification).
Judging from the OP, the Semaphore-approach seems a bit fragile, because 
if a thread misses the "go" twice, another thread won't stop as expected 
(because a down is missing).
Generally, semaphores are very powerful and just as error prone. That's 
why higher-level synchronization primitives should be preferred, if 
available.
Regards,
Tobias