Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2008-08-12 12:22:02


Zeljko Vrba wrote:
> On Mon, Aug 11, 2008 at 10:57:23PM +0300, Peter Dimov wrote:
>>
>> Oops. The queue is empty. So C does sleep, awaiting a push. Why is
>> this a problem?
>>
> Not a problem in this particular case.

Signaling outside the mutex lock is a textbook CV use which POSIX condition
variables explicitly support (their implementation can be much simpler if
they do not have to). You're welcome to not use it if you like, but there's
nothing inherently wrong with it and it doesn't have anything to do with the
original question.

> A more elaborate example of what can easily go wrong with signaling
> outside of critical section:
> http://groups.google.com/group/comp.programming.threads/browse_thread/thread/23dd5883dc36d14a?tvc=2

We had a similar thread a while ago. It's true that moving the signal inside
the lock can solve such a CV destruction race. It might be interesting to
discuss an example (if you have one) which is not easily rewritten to not
have this 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