Waiter interfacev0.1.0
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.
| Name | Type | Description |
|---|---|---|
span | Duration | how much time to wait for |
Returns: what is left of span, or why the wait did not happen
Implementations
| Type | Summary |
|---|---|
SystemWaiter | The wait every supported system actually provides. |
Related
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.
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
Implements Waiter
SystemWaiter conforms to Waiter.