ResetEvent is a thread-safe bool which can be set to true/false (“set”/“unset”). It can also block threads until the “bool” is set with cancellation via timed waits. ResetEvent can be statically initialized and is at most @sizeOf(u64)
large.
Functions
fn isSet(self: *const ResetEvent) bool
Returns if the ResetEvent was set(). Once reset() is called, this returns false…
Returns if the ResetEvent was set(). Once reset() is called, this returns false until the next set(). The memory accesses before the set() can be said to happen before isSet() returns true.
fn reset(self: *ResetEvent) void
Unmarks the ResetEvent from its “set” state if set() was called previously. It …
Unmarks the ResetEvent from its “set” state if set() was called previously. It is undefined behavior is reset() is called while threads are blocked in wait() or timedWait(). Concurrent calls to set(), isSet() and reset() are allowed.
fn set(self: *ResetEvent) void
Marks the ResetEvent as “set” and unblocks any threads in
wait()
or `timedWait…Marks the ResetEvent as “set” and unblocks any threads in
wait()
ortimedWait()
to observe the new state. The ResetEvent says “set” until reset() is called, making future set() calls do nothing semantically. The memory accesses before set() can be said to happen before isSet() returns true or wait()/timedWait() return successfully.fn timedWait(self: *ResetEvent, timeout_ns: u64) error{Timeout}!void
Block’s the callers thread until the ResetEvent is set(), or until the correspon…
Block’s the callers thread until the ResetEvent is set(), or until the corresponding timeout expires. If the timeout expires before the ResetEvent is set,
error.Timeout
is returned. This is effectively a more efficient version ofwhile (!isSet()) {}
. The memory accesses before the set() can be said to happen before timedWait() returns without error.fn wait(self: *ResetEvent) void
Block’s the callers thread until the ResetEvent is set(). This is effectively a…
Block’s the callers thread until the ResetEvent is set(). This is effectively a more efficient version of
while (!isSet()) {}
. The memory accesses before the set() can be said to happen before wait() returns.