
Hello, the docs for condition::wait say: blocks the current thread of execution until readied by a call to <code>this->notify_one()</code> or<code> this->notify_all()</code>, and then reacquires the lock. Shouldn't the docs also mention 'spurious wakeups', that is returns from wait without any notify_one or notify_all coll? I won't pretend to know why those wakeups can happen and on what systems, but at least is relevant to pthreads conditions. I'm asking because a colleague just read this, and though that a parent thread can launch child thread and wait for it to become ready with just condition.wait(); on parents side and condition.notify_one(); on child's side, while in fact return from condition.wait() only means that the predicate waited on must be reevaluated. - Volodya

Vladimir Prus wrote:
Hello, the docs for condition::wait say:
blocks the current thread of execution until readied by a call to <code>this->notify_one()</code> or<code> this->notify_all()</code>, and then reacquires the lock.
Shouldn't the docs also mention 'spurious wakeups', that is returns from wait without any notify_one or notify_all coll? I won't pretend to know why those wakeups can happen and on what systems, but at least is relevant to pthreads conditions.
FWIW, this has been brought up here a few weeks ago (including a patch). There was no response to that message, IIRC. Older versions of the documentation mentioned spurious wakeups. Regards, m

Martin Wille wrote:
Vladimir Prus wrote:
Hello, the docs for condition::wait say:
blocks the current thread of execution until readied by a call to <code>this->notify_one()</code> or<code> this->notify_all()</code>, and then reacquires the lock.
Shouldn't the docs also mention 'spurious wakeups', that is returns from wait without any notify_one or notify_all coll? I won't pretend to know why those wakeups can happen and on what systems, but at least is relevant to pthreads conditions.
FWIW, this has been brought up here a few weeks ago (including a patch). There was no response to that message, IIRC. Older versions of the documentation mentioned spurious wakeups.
I've just applied that patch. However, as I mentioned in my reply to that message, I wasn't able to verify the change. Mike
participants (3)
-
Martin Wille
-
Michael Glassford
-
Vladimir Prus