Debian Codegraph @

vendor/wit-component/tests/interfaces/wasi-http/deps/clocks/monotonic-clock.wit

raw
1 package wasi:[email protected];
2 /// WASI Monotonic Clock is a clock API intended to let users measure elapsed
3 /// time.
4 ///
5 /// It is intended to be portable at least between Unix-family platforms and
6 /// Windows.
7 ///
8 /// A monotonic clock is a clock which has an unspecified initial value, and
9 /// successive reads of the clock will produce non-decreasing values.
10 ///
11 /// It is intended for measuring elapsed time.
12 interface monotonic-clock {
13 use wasi:io/[email protected].{pollable};
14
15 /// An instant in time, in nanoseconds. An instant is relative to an
16 /// unspecified initial value, and can only be compared to instances from
17 /// the same monotonic-clock.
18 type instant = u64;
19
20 /// A duration of time, in nanoseconds.
21 type duration = u64;
22
23 /// Read the current value of the clock.
24 ///
25 /// The clock is monotonic, therefore calling this function repeatedly will
26 /// produce a sequence of non-decreasing values.
27 now: func() -> instant;
28
29 /// Query the resolution of the clock. Returns the duration of time
30 /// corresponding to a clock tick.
31 resolution: func() -> duration;
32
33 /// Create a `pollable` which will resolve once the specified instant
34 /// occured.
35 subscribe-instant: func(
36 when: instant,
37 ) -> pollable;
38
39 /// Create a `pollable` which will resolve once the given duration has
40 /// elapsed, starting at the time at which this function was called.
41 /// occured.
42 subscribe-duration: func(
43 when: duration,
44 ) -> pollable;
45 }