diff --git a/imports.md b/imports.md index a222bf8..2cbf690 100644 --- a/imports.md +++ b/imports.md @@ -18,7 +18,27 @@ at once.

resource pollable


Functions

-

poll-list: func

+

[method]pollable.ready: func

+

Return the readiness of a pollable. This function never blocks.

+

Returns true when the pollable is ready, and false otherwise.

+
Params
+ +
Return values
+ +

[method]pollable.block: func

+

block returns immediately if the pollable is ready, and otherwise +blocks until ready.

+

This function is equivalent to calling poll.poll on a list +containing only this pollable.

+
Params
+ +

poll: func

Poll for completion on a set of pollables.

This function takes a list of pollables, which identify I/O sources of interest, and waits until one or more of the events is ready for I/O.

@@ -34,19 +54,11 @@ the pollables has an error, it is indicated by marking the source as being reaedy for I/O.

Params
Return values
-

poll-one: func

-

Poll for completion on a single pollable.

-

This function is similar to poll-list, but operates on only a single -pollable. When it returns, the handle is ready for I/O.

-
Params
-

Import interface wasi:io/streams

WASI I/O is an I/O abstraction API which is currently focused on providing diff --git a/wit/deps.lock b/wit/deps.lock index 7c506be..1c063bc 100644 --- a/wit/deps.lock +++ b/wit/deps.lock @@ -1,9 +1,9 @@ [clocks] url = "https://github.com/WebAssembly/wasi-clocks/archive/main.tar.gz" -sha256 = "74844f8bf1d356bb44aab64a2f917d7a3bcb6d6924662d2e3909aeabda01bea6" -sha512 = "ef21339a60a3f4a37eb48ab81b411c1f2ed11c9b23da04d1e384c07dd4cc75f1a433ce7b46201c693b7a59b51c73d888bc41c78ad204fe32d8a312a9f9a48eb0" +sha256 = "8d6b9f7a8bf9466bdc68043c33e054878fdf09c1cc69c19c99eeadd3bb257a90" +sha512 = "21b65d911930c4512bb3caa08459283fc70b1ccc5159313092334cffd6662fb92cfe90577b51829ef363e2d02530802c88f2a1f82db43964d1f8bff7ecbc794b" [io] url = "https://github.com/WebAssembly/wasi-io/archive/main.tar.gz" -sha256 = "027671996ef6e3bedd160a6ca6631184cf68d7b36497225316c1726a5d0eb078" -sha512 = "2a3fee2c5acc2091dec45a929ff3d857e75a1970fd64d2f3ce5faad2a0d5fb3df0ad8c5f09a97c1ade8c5986317993058d141a5922b19dfbdaf97041a9bde7aa" +sha256 = "fb76f4449eea54d06b56fc6a7ca988da51bd84a54d2021cf18da67b5e2c7ebcf" +sha512 = "c005e2a91522958a9537827a49ae344e1cb39d66e85492901a86bcc7e322ba8d0a7f1a02c9b9f840c123b4ad97e297355fac98d4822536d1426d1096dd1d73ac" diff --git a/wit/deps/clocks/monotonic-clock.wit b/wit/deps/clocks/monotonic-clock.wit index d9ac7cb..afacdbb 100644 --- a/wit/deps/clocks/monotonic-clock.wit +++ b/wit/deps/clocks/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; } diff --git a/wit/deps/io/poll.wit b/wit/deps/io/poll.wit index 254f534..0829a7d 100644 --- a/wit/deps/io/poll.wit +++ b/wit/deps/io/poll.wit @@ -3,8 +3,21 @@ package wasi:io; /// A poll API intended to let users wait for I/O events on multiple handles /// at once. interface poll { - /// A "pollable" handle. - resource pollable; + /// `pollable` epresents a single I/O event which may be ready, or not. + resource pollable { + + /// Return the readiness of a pollable. This function never blocks. + /// + /// Returns `true` when the pollable is ready, and `false` otherwise. + ready: func() -> bool; + + /// `block` returns immediately if the pollable is ready, and otherwise + /// blocks until ready. + /// + /// This function is equivalent to calling `poll.poll` on a list + /// containing only this pollable. + block: func(); + } /// Poll for completion on a set of pollables. /// @@ -24,11 +37,5 @@ interface poll { /// do any I/O so it doesn't fail. If any of the I/O sources identified by /// the pollables has an error, it is indicated by marking the source as /// being reaedy for I/O. - poll-list: func(in: list>) -> list; - - /// Poll for completion on a single pollable. - /// - /// This function is similar to `poll-list`, but operates on only a single - /// pollable. When it returns, the handle is ready for I/O. - poll-one: func(in: borrow); + poll: func(in: list>) -> list; }