Debian Codegraph @

.cargo/vendor/wasip2/wit/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 @since(version = 0.2.0)
11 interface monotonic-clock {
12 @since(version = 0.2.0)
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 @since(version = 0.2.0)
19 type instant = u64;
20
21 /// A duration of time, in nanoseconds.
22 @since(version = 0.2.0)
23 type duration = u64;
24
25 /// Read the current value of the clock.
26 ///
27 /// The clock is monotonic, therefore calling this function repeatedly will
28 /// produce a sequence of non-decreasing values.
29 @since(version = 0.2.0)
30 now: func() -> instant;
31
32 /// Query the resolution of the clock. Returns the duration of time
33 /// corresponding to a clock tick.
34 @since(version = 0.2.0)
35 resolution: func() -> duration;
36
37 /// Create a `pollable` which will resolve once the specified instant
38 /// has occurred.
39 @since(version = 0.2.0)
40 subscribe-instant: func(
41 when: instant,
42 ) -> pollable;
43
44 /// Create a `pollable` that will resolve after the specified duration has
45 /// elapsed from the time this function is invoked.
46 @since(version = 0.2.0)
47 subscribe-duration: func(
48 when: duration,
49 ) -> pollable;
50 }