File: monotonic-clock.wit

package info (click to toggle)
rust-wasmtime 26.0.1%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 48,492 kB
  • sloc: ansic: 4,003; sh: 561; javascript: 542; cpp: 254; asm: 175; ml: 96; makefile: 55
file content (50 lines) | stat: -rw-r--r-- 1,669 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package wasi:clocks@0.2.1;
/// WASI Monotonic Clock is a clock API intended to let users measure elapsed
/// time.
///
/// It is intended to be portable at least between Unix-family platforms and
/// Windows.
///
/// A monotonic clock is a clock which has an unspecified initial value, and
/// successive reads of the clock will produce non-decreasing values.
@since(version = 0.2.0)
interface monotonic-clock {
    @since(version = 0.2.0)
    use wasi:io/poll@0.2.1.{pollable};

    /// An instant in time, in nanoseconds. An instant is relative to an
    /// unspecified initial value, and can only be compared to instances from
    /// the same monotonic-clock.
    @since(version = 0.2.0)
    type instant = u64;

    /// A duration of time, in nanoseconds.
    @since(version = 0.2.0)
    type duration = u64;

    /// Read the current value of the clock.
    ///
    /// The clock is monotonic, therefore calling this function repeatedly will
    /// produce a sequence of non-decreasing values.
    @since(version = 0.2.0)
    now: func() -> instant;

    /// Query the resolution of the clock. Returns the duration of time
    /// corresponding to a clock tick.
    @since(version = 0.2.0)
    resolution: func() -> duration;

    /// Create a `pollable` which will resolve once the specified instant
    /// has occurred.
    @since(version = 0.2.0)
    subscribe-instant: func(
        when: instant,
    ) -> pollable;

    /// Create a `pollable` that will resolve after the specified duration has
    /// elapsed from the time this function is invoked.
    @since(version = 0.2.0)
    subscribe-duration: func(
        when: duration,
    ) -> pollable;
}