
8 Oct
2006
8 Oct
'06
12:44 p.m.
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