
18 Oct
2007
18 Oct
'07
10:56 a.m.
Johan Nilsson wrote:
It's possible to handle spurious wakeups with relative times as well, perhaps just not perfectly (depending on underlying platform support). If the only way to perform a timed wait on a condition variable is by an absolute time, I believe the most common usage will be something like this (pseudocode):
--- time now = microsec_clock::local_time(); time timeout = now + milliseconds(250); if (!cv.timed_wait(lk, timeout, my_pred())) { throw "Timed out!"; }
You are missing a loop.