
4 Feb
2009
4 Feb
'09
4:23 p.m.
AMDG 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 wakeups. In Christ, Steven Watanabe