wait
Atomically releases the Mutex, blocks the caller thread, then re-acquires the Mutex on return. "Atomically" here refers to accesses done on the Condition after acquiring the Mutex.
The Mutex must be locked by the caller's thread when this function is called. A Mutex can have multiple Conditions waiting with it concurrently, but not the opposite. It is undefined behavior for multiple threads to wait ith different mutexes using the same Condition concurrently. Once threads have finished waiting with one Mutex, the Condition can be used to wait with another Mutex.
A blocking call to wait() is unblocked from one of the following conditions:
- a spurious ("at random") wake up occurs
- a future call to
signal()orbroadcast()which has acquired the Mutex and is sequenced after thiswait().
Given wait() can be interrupted spuriously, the blocking condition should be checked continuously
irrespective of any notifications from signal() or broadcast().
Function parameters
Parameters
- self:*Condition
- mutex:*Mutex
Atomically releases the Mutex, blocks the caller thread, then re-acquires the Mutex on return.
Functions
- wait
- Atomically releases the Mutex, blocks the caller thread, then re-acquires the Mutex on return.
- timedWait
- Atomically releases the Mutex, blocks the caller thread, then re-acquires the Mutex on return.
- signal
- Unblocks at least one thread blocked in a call to `wait()` or `timedWait()` with a given Mutex.
- broadcast
- Unblocks all threads currently blocked in a call to `wait()` or `timedWait()` with a given Mutex.
Source