Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2006-10-09 08:56:40


Alexander Terekhov wrote:
> Peter Dimov wrote:
>>
>> Alexander Terekhov wrote:
>>> Peter Dimov wrote:
>>>>
>>>> Pavel Syomin wrote:
>>>>
>>>>> This is solve my problems, but why there is nothing about spurious
>>>>> wakeup in boost documentation?...
>>>>
>>>> The older documentation
>>>>
>>>> http://web.archive.org/web/20041024220516/boost.org/libs/thread/doc/condition.html
>>>>
>>>> does have a few sentences that mention spurious wakeups; I've no
>>>> idea how they got lost. I'll CC: the dev list.
>>>
>>> The docu might tell something not only about spurious wakeups but
>>> also about the fact that return of timedout status doesn't preclude
>>> consumption of a signal issued concurrently (note that thread
>>> cancel delivery does preclude it).
>>
>> Hey!
>>
>> Does this mean that timed_wait( lock, xt, pred ) has a bug? Instead
>> of
>>
>> while (!pred()) { if (!timed_wait(lock, xt)) return false; } return
>> true;
>>
>> it needs to be
>>
>> while (!pred()) { if (!timed_wait(lock, xt)) return pred(); } return
>> true;
>>
>> otherwise a 'false' return can consume a signal meant for someone
>> else without notifying the caller to handle the pred() == true case?
>
> Yup.
>
> Another possible fix is to broadcast() (signal() is not enough).
>
> while (!pred()) { if (!timed_wait(lock, xt)) return broadcast(),
> false; }

Ummmm.... why is signal() not enough?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk