Clocks v0.1.0

Source
Reading clocks and sleeping.

ClockRealtime

pub const ClockRealtime: int32 = 0;

CLOCK_REALTIME: wall-clock time, which can jump when the system clock is set.

Source

ClockMonotonic

pub const ClockMonotonic: int32 = 4;

CLOCK_MONOTONIC: time since an unspecified point, which never goes backwards.

Source

ClockGetTime

pub func ClockGetTime(
    clockId: int32,
    time: *var Timespec
) -> int64

Reads clockId into time. Returns zero, or a negative error number. time must be non-null and writable.

Source

Parameters

NameTypeDescription
clockIdint32which clock to read
time*var Timespecreceives the reading

Returns: zero, or a negative error number

Nanosleep

pub func Nanosleep(
    request: *Timespec,
    remaining: *var Timespec
) -> int64

Suspends the caller for the requested duration. remaining is written when a signal cut the wait short, and may be null. Returns zero, or a negative error number; EINTR with the unslept time in remaining is how a signal is reported. request must be non-null, and its nanoseconds must be under one second.

Source

Parameters

NameTypeDescription
request*Timespechow long to wait
remaining*var Timespecreceives the unslept time when a signal cut the wait short, and may be null

Returns: zero, or a negative error number

ClockMonotonicFast

pub const ClockMonotonicFast: int32 = 12;

CLOCK_MONOTONIC_FAST: like ClockMonotonic, read from a cached value rather than the hardware. Cheaper and coarser. FreeBSD offers this pairing where Linux offers a coarse clock under a different number.

Source

ClockRealtimeFast

pub const ClockRealtimeFast: int32 = 10;

CLOCK_REALTIME_FAST: like ClockRealtime, read from a cached value.

Source

ClockProcessCpuTime

pub const ClockProcessCpuTime: int32 = 15;

CLOCK_PROCESS_CPUTIME_ID: processor time this process has used.

Source

ClockGetResolution

pub func ClockGetResolution(
    clockId: int32,
    resolution: *var Timespec
) -> int64

Reads the resolution of clockId into resolution. Returns zero, or a negative error number. The resolution is the granularity the clock advances by, not the cost of reading it and not a promise about accuracy. resolution must be non-null and writable.

Source

Parameters

NameTypeDescription
clockIdint32which clock to describe
resolution*var Timespecreceives the granularity

Returns: zero, or a negative error number