Skip to content

Commit 01be518

Browse files
committed
Convert to Resources, and other API cleanups.
- Convert to resources. Use resources instead of `u32`s, remove drop functions, `this` arguments, and rename `subscribe-to-*` to just `subscribe`, as discussed in WebAssembly/wasi-poll#21. - Merge wasi-poll into wasi-io. These two proposals are closely related to each other, so it makes sense to have them together. - While here, tidy up the poll API, incorporating ideas discussed in WebAssembly/wasi-poll#220: - Rename `poll-oneoff` to `poll-list`, and add a `poll-one`. - Change `poll-oneoff`'s return type from `list<bool>` to `list<u32>`, because in the common case, this should allow it to create much smaller allocations.
1 parent 4bf705c commit 01be518

File tree

9 files changed

+644
-716
lines changed

9 files changed

+644
-716
lines changed

example-world.md

Lines changed: 0 additions & 417 deletions
This file was deleted.

imports.md

Lines changed: 384 additions & 0 deletions
Large diffs are not rendered by default.

wit/deps.lock

Lines changed: 0 additions & 4 deletions
This file was deleted.

wit/deps.toml

Lines changed: 0 additions & 1 deletion
This file was deleted.

wit/deps/poll/poll.wit

Lines changed: 0 additions & 49 deletions
This file was deleted.

wit/deps/poll/world.wit

Lines changed: 0 additions & 5 deletions
This file was deleted.

wit/poll.wit

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package wasi:io
2+
3+
/// A poll API intended to let users wait for I/O events on multiple handles
4+
/// at once.
5+
interface poll {
6+
/// A "pollable" handle.
7+
resource pollable
8+
9+
/// Poll for completion on a set of pollables.
10+
///
11+
/// This function takes a list of pollables, which identify I/O sources of
12+
/// interest, and waits until one or more of the events is ready for I/O.
13+
///
14+
/// The result `list<u32>` contains one or more indices of handles in the
15+
/// argument list that is ready for I/O.
16+
///
17+
/// If the list contains more elements than can be indexed with a `u32`
18+
/// value, this function traps.
19+
///
20+
/// A timeout can be implemented by adding a pollable from the
21+
/// wasi-clocks API to the list.
22+
///
23+
/// This function does not return a `result`; polling in itself does not
24+
/// do any I/O so it doesn't fail. If any of the I/O sources identified by
25+
/// the pollables has an error, it is indicated by marking the source as
26+
/// being reaedy for I/O.
27+
poll-list: func(in: list<pollable>) -> list<u32>
28+
29+
/// Poll for completion on a single pollable.
30+
///
31+
/// This function is similar to `poll-list`, but operates on only a single
32+
/// pollable. When it returns, the handle is ready for I/O.
33+
poll-one: func(in: pollable)
34+
}

0 commit comments

Comments
 (0)