Skip to content

Commit

Permalink
Document per-item versions using @since gates
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshuawuyts committed May 28, 2024
1 parent 6cfb0f8 commit efeeb46
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
9 changes: 8 additions & 1 deletion wit/monotonic-clock.wit
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,42 @@ package wasi:[email protected];
///
/// 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 {
use wasi:io/poll@0.2.0.{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.
/// has occured.
@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;
Expand Down
4 changes: 4 additions & 0 deletions wit/wall-clock.wit
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ package wasi:[email protected];
/// monotonic, making it unsuitable for measuring elapsed time.
///
/// It is intended for reporting the current date and time for humans.
@since(version = 0.2.0)
interface wall-clock {
/// A time and date in seconds plus nanoseconds.
@since(version = 0.2.0)
record datetime {
seconds: u64,
nanoseconds: u32,
Expand All @@ -33,10 +35,12 @@ interface wall-clock {
///
/// [POSIX's Seconds Since the Epoch]: https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap04.html#tag_21_04_16
/// [Unix Time]: https://en.wikipedia.org/wiki/Unix_time
@since(version = 0.2.0)
now: func() -> datetime;

/// Query the resolution of the clock.
///
/// The nanoseconds field of the output is always less than 1000000000.
@since(version = 0.2.0)
resolution: func() -> datetime;
}
3 changes: 3 additions & 0 deletions wit/world.wit
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package wasi:clocks@0.2.0;

@since(version = 0.2.0)
world imports {
@since(version = 0.2.0)
import monotonic-clock;
@since(version = 0.2.0)
import wall-clock;
}

0 comments on commit efeeb46

Please sign in to comment.