Skip to content

std/timer

Scheduling primitives for delaying the current task.

Timer is separate from Instant and Duration: those modules describe time values, while this module performs time-based waiting.

Import with import std/timer.

Modules

fn sleep(d: Duration): Unit

Suspends the current task for the given duration.

When called inside a concurrent { } block, cancellation of that block’s context ends the sleep early without producing a user-visible error.