DoxigAlpha

init

Create the deadline to expire after the given amount of time in nanoseconds passes. Pass in null to have the deadline call Futex.wait() and never expire.

Function parameters

Parameters

#
expires_in_ns:?u64

Deadline is used to wait efficiently for a pointer's value to change using Futex and a fixed timeout.

Types

#
Deadline
Deadline is used to wait efficiently for a pointer's value to change using Futex and a fixed timeout.

Checks if `ptr` still contains the value `expect` and, if so, blocks the caller until either:

Functions

#
wait
Checks if `ptr` still contains the value `expect` and, if so, blocks the caller until either:
timedWait
Checks if `ptr` still contains the value `expect` and, if so, blocks the caller until either:
wake
Unblocks at most `max_waiters` callers blocked in a `wait()` call on `ptr`.

Source

Implementation

#
pub fn init(expires_in_ns: ?u64) Deadline {
    var deadline: Deadline = undefined;
    deadline.timeout = expires_in_ns;

    // std.time.Timer is required to be supported for somewhat accurate reportings of error.Timeout.
    if (deadline.timeout != null) {
        deadline.started = std.time.Timer.start() catch unreachable;
    }

    return deadline;
}