The code Kevin highlighted does look a bit odd - overly verbose (two tests for "appeared") and dealing with spurious wakeups strangely. The canonical form is:
while (!/*condition*/)
{
if (cv.wait_until(lock, deadline) == st::cv_status::timeout)
throw /* timed out */;
}
The code Kevin highlighted does look a bit odd - overly verbose (two tests for "appeared") and dealing with spurious wakeups strangely. The canonical form is:
while (!/*condition*/) until(lock, deadline) == st::cv_ status: :timeout)
{
if (cv.wait_
throw /* timed out */;
}