Silk

silk/os_monotonic_clock

Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, x86_64-unknown-linux-gnu.

Native monotonic clock provider with source-derived relative waiting.

When to use

Construct OsMonotonicClock at a native application edge for elapsed-time measurement and blocking deadlines. Use a scripted provider when tests need virtual advancement.

Details

Construction performs no host call. Reads, resolution queries, and absolute waits use selected ordinary libc declarations and source-owned policy. waitFor performs exactly one starting read and uses checked split-field deadline arithmetic. It then uses the same absolute-wait operation as waitUntil.

Gotchas

Marks and deadlines are meaningful only on this provider's monotonic timeline. Native waits block the calling host thread; they do not park one Fiber. Failure, malformed host output, or deadline overflow is a fatal trap. Linux requires glibc 2.17 or later and excludes system suspend time from this clock. macOS includes system suspend time. WebAssembly and no-libc selection leave this module empty.

Import as OsMonotonicClock with import silk.os_monotonic_clock { OsMonotonicClock }.

Public declarations: 1.

OsMonotonicClock

pub struct OsMonotonicClock

A stateless native provider; construction makes no call and failed operations trap.

Associated function OsMonotonicClock.make

pub fn make() -> OsMonotonicClock

Creates a native clock provider without reading the clock or installing a default.

Implementation MonotonicClock for OsMonotonicClock

impl MonotonicClock for OsMonotonicClock

Operation now

now = OsMonotonicClock.impl@0.now

Operation getResolution

getResolution = OsMonotonicClock.impl@0.getResolution

Operation waitUntil

waitUntil = OsMonotonicClock.impl@0.waitUntil

Operation waitFor

waitFor = OsMonotonicClock.impl@0.waitFor

On this page