Cond.wait

Atomically releases mutex and waits until cond is signalled. When this function returns, mutex is locked again and owned by the calling thread.

When using condition variables, it is possible that a spurious wakeup may occur (ie: Cond.wait returns even though Cond.signal was not called). It's also possible that a stolen wakeup may occur. This is when Cond.signal is called, but another thread acquires mutex before this thread and modifies the state of the program in such a way that when Cond.wait is able to return, the expected condition is no longer met.

For this reason, Cond.wait must always be used in a loop. See the documentation for glib.Cond for a complete example.

class Cond
void
wait

Parameters

mutex Mutex

a glib.Mutex that is currently locked