Waiter interfacev0.1.0

Source
One wait, however the caller reaches the system.
pub interface Waiter {
    func WaitFor(
        self: &var Self,
        span: Duration
    ) -> Duration ! TimeError;
}

An implementation waits for at most span and reports what is left of it. Reporting less than the whole span as remaining is how a wait says it did some of the work, including when a signal stopped it early; failing is how it says the system refused. SleepFor drives whichever implementation it is given until nothing is left.

Requirements

WaitFor

func WaitFor(
    self: &var Self,
    span: Duration
) -> Duration ! TimeError

Waits for at most span, and reports what remains of it. Succeeds with the unwaited part, which is zero when the whole span was waited for and more than zero when something stopped the wait early with time still to go. Fails when the system refused the wait. An implementation must not succeed with zero unless the span really elapsed.

NameTypeDescription
spanDurationhow much time to wait for

Returns: what is left of span, or why the wait did not happen

Source

Implementations

TypeSummary
SystemWaiterThe wait every supported system actually provides.

SystemWaiter

pub struct SystemWaiter {
    // private fields
}

The wait every supported system actually provides. Copy. Holds nothing: the system is the state. Construct one with SystemWaiter() and hand it to SleepUsing, or use SleepFor, which does that.

Source

Constructors

SystemWaiter

pub func SystemWaiter() -> SystemWaiter

A waiter that reaches the operating system. Cannot fail. Runs in constant time and allocates nothing.

Returns: the waiter

Source

Implements Waiter

SystemWaiter conforms to Waiter.