Boost logo

Boost :

Subject: Re: [boost] [threads] API Design Question
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-02-04 11:23:53


Alexander Bernauer wrote:
> Why is it, that the wait and timed_wait functions of the
> condition_variable class do not encapsulate the problem of spurious
> wakeups?
> I wonder whether there are good reasons. I have seen libraries which do
> so. Do they miss a corner case?

For one thing, the code that you posted requires the lock to be
held when calling notify.

Also, it's better in general to use the overloads of wait that
take a predicate, since these do provide protection from spurious

In Christ,
Steven Watanabe

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