Skip to main content
load(“@std//time.axl”, “sleep”, “sleep_iter”, “monotonic”, “monotonic_ns”, “now_ms”, “time”)
function sleep
def sleep(ms: int) -> None
Blocks the current thread for ms milliseconds. Returns None. The sleep is synchronous; the calling task’s thread is parked for the full duration. It is a safe point: once ctx.cancellation.root is cancelled the task exits instead, unless intercept() is in effect.

Examples

function sleep_iter
def sleep_iter(ms: int) -> typing.Iterable[int]
Returns an infinite iterator that yields a monotonically increasing integer every ms milliseconds. Each call to next sleeps for ms milliseconds, then returns the next tick (starting at 0). Use break to stop iteration. The iterator never ends on its own: a loop that owns the ending (ctx.cancellation.intercept()) checks its token and breaks. Without intercept(), a cancelled root ends the task at the loop as Ctrl+C asks.

Examples

function monotonic
def monotonic() -> float
Returns a monotonically non-decreasing time in seconds as a float. The reference epoch is fixed at process start, so values are only meaningful relative to other monotonic() readings within the same process. Suitable for measuring elapsed time.

Examples

function monotonic_ns
def monotonic_ns() -> int
Returns a monotonically non-decreasing time in nanoseconds as an int. The reference epoch is fixed at process start, so values are only meaningful relative to other monotonic_ns() readings within the same process. Higher precision than monotonic().

Examples

function now_ms
def now_ms() -> int
Returns the wall-clock time in milliseconds since the Unix epoch. Unlike monotonic*, this is real calendar time and is comparable across processes — use it to stamp events, not to measure elapsed time (a clock adjustment can make it jump). Returns 0 if the system clock is set before the epoch.

Examples

property time
time: struct(monotonic = function, monotonic_ns = function, now_ms = function, sleep = function, sleep_iter = function)