You are talking about CondVar
and not Condition
, right? Classic condition variables always need a predicate because they do not ‘know’ that they have been signalled. If the async operation is very fast, the callback may be scheduled before the main routine calls wait
. In this case, signalOne
has no effect because the routine isn’t waiting yet. Without the predicate, the subsequent wait
call would block forever because nobody will signal it. With the predicate, it will just return immediately without waiting.
Yeah, that’s how Condition
is supposed to be used. I got a bit confused there.