Skip to main content

CpuClockHook

Type Alias CpuClockHook 

Source
pub type CpuClockHook = fn() -> f64;
Expand description

Function-pointer signature for retrieving program CPU time in seconds.

Backs os.clock. C’s clock() reads CLOCK_PROCESS_CPUTIME_ID, which has no std equivalent and is unavailable on bare WASM; the stdlib falls back to a monotonic wall-clock baseline (matching wasi-libc/Emscripten’s emulation) when this hook is unset. A host wanting true CPU time can install one (e.g. via the cpu-time crate) without changing the sandboxed crates.