Boost logo

Boost Users :

From: Pavel Syomin (syomin_at_[hidden])
Date: 2006-09-20 08:13:01


Peter Dimov wrote:
> You are assuming that when condition::(timed_)wait returns the predicate (in
> your case m_counter != 0) is guaranteed to be true. This is not correct.
> condition::wait is allowed to return at any time (this is known as a
> "spurious wakeup".) You need to use a while loop.
>
> while( m_counter == 0 )
> {
> if( !m_condition.timed_wait( lock, time ) ) return; // timeout
> }
>
> assert( m_counter != 0 );
> --m_counter;
>
> I'm almost 100% certain that this was in the documentation once, but I can't
> find it now. Maybe it somehow got lost in the transition to the new doc
> layout.
>
Thank you!
This is solve my problems, but why there is nothing about spurious
wakeup in boost documentation?...


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