Boost logo

Boost :

From: Roland Schwarz (roland.schwarz_at_[hidden])
Date: 2006-10-08 08:44:59


Peter Dimov wrote:
> 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?

The documentation states:

Returns: false if xt is reached, otherwise true.

So if it returned pred instead you wouldn't get the correct result.
I.e. when using the timed_wait you are deliberately missing the
signal when it arrives out of time. It simply does not matter if
the signal arrived after timeout. Or did I misunderstand your
concerns?

Roland


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