Module std::time
Time as an effect: code reads the clock and waits on it only through a Clock capability in
its row, so its caller decides which clock it reads. Every executor (std::task::Pool,
std::net::Evented) handles it with the monotonic clock in nanoseconds; a test uses
std::sim::SimClock or the virtual time of std::sim::world.
Source: std/time.weir; committed interface: std/time.iface. Index
- effect
Clock: Reading the time and waiting: handled by every executor, or bystd::sim::SimClockalone.
effect Clock
pub effect Clock {
fn now() -> Int;
once fn sleep(d: Int);
}
Reading the time and waiting: handled by every executor, or by std::sim::SimClock alone.
op now
fn now() -> Int;
Control kind tail: the clause's result is the op's, and the performer goes on, never aborted or suspended.
The current time, in ticks of the handler's choosing (nanoseconds on a real executor).
op sleep
once fn sleep(d: Int);
Control kind once: the clause takes the continuation (cont k) and resumes or cancels it, so the perform is a suspension and an abort edge.
Waits until d ticks have passed (none when d is not positive). A once op: an
executor parks the task and runs others meanwhile; a clock that runs no tasks answers at once.