zena:time
zena
import {…} from 'zena:time';
Monotonic time measurement, durations, and timers.
Provides Instant for points in time, Duration for spans of time,
monotonic() for reading the system monotonic clock, and sleep(duration)
for asynchronous waiting.
Examples ​
zena
import { monotonic, sleep, milliseconds } from 'zena:time';
let start = monotonic();
await sleep(milliseconds(50));
let elapsed = monotonic() - start;
Classes
Instant
zena
final extension class Instant
A point on the monotonic clock: nanoseconds from an arbitrary origin, so only the distance between two instants is meaningful.
Methods
Duration
zena
final extension class Duration
A signed span of time, in nanoseconds.
Methods
Functions
sleep
zena
function sleep(d: Duration): Future<void>
A future that completes after at least d.
monotonic
zena
function monotonic(): Instant
The monotonic clock's reading.
Reads the clock directly rather than through the installed Clock:
only the parker path — sleep, park, wait — needs the installation,
and a clock read should not pay a registration check.
milliseconds
zena
function milliseconds(ms: i64): Duration
ms milliseconds as a Duration.
nanoseconds
zena
function nanoseconds(ns: i64): Duration
ns nanoseconds as a Duration.