diff --git a/imports.md b/imports.md index 3f38661..e08b326 100644 --- a/imports.md +++ b/imports.md @@ -15,7 +15,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.

@@ -31,19 +51,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/poll.wit b/wit/poll.wit index 254f534..0829a7d 100644 --- a/wit/poll.wit +++ b/wit/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; }