|
1 | | -package wasi:clocks@0.3.0-rc-2025-08-15; |
| 1 | +package wasi:clocks@0.3.0-rc-2025-09-16; |
2 | 2 | /// WASI Monotonic Clock is a clock API intended to let users measure elapsed |
3 | 3 | /// time. |
4 | 4 | /// |
|
7 | 7 | /// |
8 | 8 | /// A monotonic clock is a clock which has an unspecified initial value, and |
9 | 9 | /// successive reads of the clock will produce non-decreasing values. |
10 | | -@since(version = 0.3.0-rc-2025-08-15) |
| 10 | +@since(version = 0.3.0-rc-2025-09-16) |
11 | 11 | interface monotonic-clock { |
| 12 | + use types.{duration}; |
| 13 | + |
12 | 14 | /// An instant in time, in nanoseconds. An instant is relative to an |
13 | 15 | /// unspecified initial value, and can only be compared to instances from |
14 | 16 | /// the same monotonic-clock. |
15 | | - @since(version = 0.3.0-rc-2025-08-15) |
| 17 | + @since(version = 0.3.0-rc-2025-09-16) |
16 | 18 | type instant = u64; |
17 | 19 |
|
18 | | - /// A duration of time, in nanoseconds. |
19 | | - @since(version = 0.3.0-rc-2025-08-15) |
20 | | - type duration = u64; |
21 | | - |
22 | 20 | /// Read the current value of the clock. |
23 | 21 | /// |
24 | 22 | /// The clock is monotonic, therefore calling this function repeatedly will |
25 | 23 | /// produce a sequence of non-decreasing values. |
26 | | - @since(version = 0.3.0-rc-2025-08-15) |
| 24 | + /// |
| 25 | + /// For completeness, this function traps if it's not possible to represent |
| 26 | + /// the value of the clock in an `instant`. Consequently, implementations |
| 27 | + /// should ensure that the starting time is low enough to avoid the |
| 28 | + /// possibility of overflow in practice. |
| 29 | + @since(version = 0.3.0-rc-2025-09-16) |
27 | 30 | now: func() -> instant; |
28 | 31 |
|
29 | 32 | /// Query the resolution of the clock. Returns the duration of time |
30 | 33 | /// corresponding to a clock tick. |
31 | | - @since(version = 0.3.0-rc-2025-08-15) |
| 34 | + @since(version = 0.3.0-rc-2025-09-16) |
32 | 35 | get-resolution: func() -> duration; |
33 | 36 |
|
34 | 37 | /// Wait until the specified instant has occurred. |
35 | | - @since(version = 0.3.0-rc-2025-08-15) |
| 38 | + @since(version = 0.3.0-rc-2025-09-16) |
36 | 39 | wait-until: async func( |
37 | 40 | when: instant, |
38 | 41 | ); |
39 | 42 |
|
40 | | - /// Wait for the specified duration has elapsed. |
41 | | - @since(version = 0.3.0-rc-2025-08-15) |
| 43 | + /// Wait for the specified duration to elapse. |
| 44 | + @since(version = 0.3.0-rc-2025-09-16) |
42 | 45 | wait-for: async func( |
43 | 46 | how-long: duration, |
44 | 47 | ); |
|
0 commit comments