Function in clock compiler

sleep_ms

fn sleep_ms(int ms)
Import
use clock::{sleep_ms};
Source: compiler/src/builtin_docs/clock.hy

Pauses for at least ms milliseconds.

Zero or a negative value returns at once. Outside a task::scope this blocks the thread; inside one it suspends only the calling task, so other tasks keep running.

Parameters#

NameType
msint

Examples#

use clock::{sleep_ms, mono_nanos};
use tests::assert;
let start = mono_nanos();
sleep_ms(10);
assert!(mono_nanos() - start >= 10000000);

See also#

  • task::scope
  • wall_nanos: Returns the current wall-clock time in nanoseconds since the Unix epoch (UTC).
  • mono_nanos: Returns monotonic nanoseconds from a process-local starting point.
↑ ↓ navigate ↵ open