From 920b60d6a30b4e93efc5d7377220eab840bb4bd2 Mon Sep 17 00:00:00 2001
From: Pat Hickey
#### `type instant` `u64` -
A timestamp in nanoseconds. +
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. +
type duration
u64
A duration of time, in nanoseconds.
now: func
instant
resolution: func
Query the resolution of the clock.
+Query the resolution of the clock. Returns the duration of time +corresponding to a clock tick.
+duration
subscribe-instant: func
Create a pollable
which will resolve once the specified instant
+occured.
subscribe: func
Create a pollable
which will resolve once the specified time has been
-reached.
subscribe-duration: func
Create a pollable
which will resolve once the given duration has
+elapsed, starting at the time at which this function was called.
+occured.
WASI Wall Clock is a clock API intended to let users query the current diff --git a/wit/monotonic-clock.wit b/wit/monotonic-clock.wit index d9ac7cb..afacdbb 100644 --- a/wit/monotonic-clock.wit +++ b/wit/monotonic-clock.wit @@ -11,22 +11,34 @@ interface monotonic-clock { use wasi:io/poll.{pollable}; - /// A timestamp in nanoseconds. + /// 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. type instant = u64; + /// A duration of time, in nanoseconds. + 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. now: func() -> instant; - /// Query the resolution of the clock. - resolution: func() -> instant; + /// Query the resolution of the clock. Returns the duration of time + /// corresponding to a clock tick. + resolution: func() -> duration; - /// Create a `pollable` which will resolve once the specified time has been - /// reached. - subscribe: func( + /// Create a `pollable` which will resolve once the specified instant + /// occured. + subscribe-instant: func( when: instant, - absolute: bool + ) -> pollable; + + /// Create a `pollable` which will resolve once the given duration has + /// elapsed, starting at the time at which this function was called. + /// occured. + subscribe-duration: func( + when: duration, ) -> pollable; }