|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2006-10-09 14:31:21
Alexander Terekhov wrote:
> Peter Dimov wrote:
> [...]
>>> 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?
>
> Threads A and B waiting (A does timed wait), C changes something,
> signals and enters wait expecting another state change followed by
> signaling from either A or B (whichever gets the signal and makes
> processing). If A times out and only re-signal, that signal can be
> consumed by C as spurious wake. So broadcast() is needed to wake B
> and let it do the job.
Terrific. Thanks Alexander.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk