Function timedWait [src]
Checks if ptr still contains the value expect and, if so, blocks the caller until either:
The value at ptr is no longer equal to expect.
The caller is unblocked by a matching wake().
The caller is unblocked spuriously ("at random").
The caller blocks for longer than the given timeout. In which case, error.Timeout is returned.
The checking of ptr and expect, along with blocking the caller, is done atomically
and totally ordered (sequentially consistent) with respect to other wait()/wake() calls on the same ptr.
Prototype
pub fn timedWait(ptr: *const atomic.Value(u32), expect: u32, timeout_ns: u64) error{Timeout}!void
Parameters
ptr: *const atomic.Value(u32)
expect: u32
timeout_ns: u64
Possible Errors
Source
pub fn timedWait(ptr: *const atomic.Value(u32), expect: u32, timeout_ns: u64) error{Timeout}!void {
@branchHint(.cold);
// Avoid calling into the OS for no-op timeouts.
if (timeout_ns == 0) {
if (ptr.load(.seq_cst) != expect) return;
return error.Timeout;
}
return Impl.wait(ptr, expect, timeout_ns);
}