Browse the docs

silk.platform.windows.time.

Exact conversions between Windows clock units and Silk instants.

When to use#

Windows providers use WindowsTime to convert FILETIME values, performance-counter ticks, and blocking-wait durations. The conversions make no host calls and work on every target.

Import as WindowsTime with import silk.platform.windows.time { WindowsTime }.

Public declarations: 1.

WindowsTime#

silk
pub struct WindowsTime

Windows timestamp and timeout conversions without allocation or host calls.

Details#

FILETIME is unsigned 100-nanosecond intervals since 1601. Performance-counter values have a nonnegative provider-local origin and a positive frequency. Invalid counter values trap.

Implementation WindowsTime#

silk
impl WindowsTime

Associated function fileTime#

silk
pub fn fileTime(intervals: u64) -> Instant

Converts unsigned 100-nanosecond intervals since 1601 to Unix time.

Details#

Every u64 input is representable. Division precedes epoch subtraction and multiplication, preserving dates before 1970 and avoiding overflow from a total nanosecond timestamp.

Associated function counter#

silk
pub fn counter(ticks: i64, frequency: i64) -> Instant

Converts nonnegative performance-counter ticks at frequency ticks per second to an instant.

Details#

Fractional nanoseconds round down. Seconds and the fraction are converted separately, so the total need not fit a nanosecond counter. Negative ticks or nonpositive frequency trap.

Associated function counterResolution#

silk
pub fn counterResolution(frequency: i64) -> u64

Returns one performance-counter tick in whole nanoseconds, rounded up to at least one. Nonpositive frequency traps. This is nominal resolution, not measured accuracy.

Associated function sleepMilliseconds#

silk
pub fn sleepMilliseconds(seconds: i64, nanoseconds: i64) -> u32

Converts a canonical nonnegative duration to a finite Windows sleep timeout in milliseconds.

Details#

Rounds up and saturates at 4,294,967,294, below Windows' infinite-wait sentinel. Callers recheck their original deadline after each sleep. Negative seconds or nanoseconds outside 0 through 999,999,999 trap.

Category: Windows platform.

Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, aarch64-unknown-linux-gnu-no-libc, x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu-no-libc, wasm32-unknown-unknown, wasm32-wasip1, wasm32-wasip2, x86_64-pc-windows-msvc, wasm64-unknown-unknown.

View the source of this page