Function wait [src]
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() or broadcast() which has acquired the Mutex and is sequenced after this wait().
Given wait() can be interrupted spuriously, the blocking condition should be checked continuously
irrespective of any notifications from signal() or broadcast().
Prototype
pub fn wait(self: *Condition, mutex: *Mutex) void
Parameters
self: *Condition
mutex: *Mutex
Source
pub fn wait(self: *Condition, mutex: *Mutex) void {
self.impl.wait(mutex, null) catch |err| switch (err) {
error.Timeout => unreachable, // no timeout provided so we shouldn't have timed-out
};
}