Clocks v0.1.0
ClockRealtime
pub const ClockRealtime: int32 = 0;
CLOCK_REALTIME: wall-clock time, which can jump when the system clock is set.
ClockMonotonic
pub const ClockMonotonic: int32 = 4;
CLOCK_MONOTONIC: time since an unspecified point, which never goes backwards.
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.
Parameters
| Name | Type | Description |
|---|---|---|
clockId | int32 | which clock to read |
time | *var Timespec | receives 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.
Parameters
| Name | Type | Description |
|---|---|---|
request | *Timespec | how long to wait |
remaining | *var Timespec | receives 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.
ClockRealtimeFast
pub const ClockRealtimeFast: int32 = 10;
CLOCK_REALTIME_FAST: like ClockRealtime, read from a cached value.
ClockProcessCpuTime
pub const ClockProcessCpuTime: int32 = 15;
CLOCK_PROCESS_CPUTIME_ID: processor time this process has used.
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.
Parameters
| Name | Type | Description |
|---|---|---|
clockId | int32 | which clock to describe |
resolution | *var Timespec | receives the granularity |
Returns: zero, or a negative error number