Skip to content

Commit

Permalink
Convert to Resources, and other API cleanups.
Browse files Browse the repository at this point in the history
 - 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#22:

   - 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.
  • Loading branch information
sunfishcode committed Sep 12, 2023
1 parent 4bf705c commit b9e6b12
Show file tree
Hide file tree
Showing 9 changed files with 646 additions and 716 deletions.
417 changes: 0 additions & 417 deletions example-world.md

This file was deleted.

386 changes: 386 additions & 0 deletions imports.md

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions wit/deps.lock

This file was deleted.

1 change: 0 additions & 1 deletion wit/deps.toml

This file was deleted.

49 changes: 0 additions & 49 deletions wit/deps/poll/poll.wit

This file was deleted.

5 changes: 0 additions & 5 deletions wit/deps/poll/world.wit

This file was deleted.

34 changes: 34 additions & 0 deletions wit/poll.wit
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
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

/// 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.
///
/// The result `list<u32>` contains one or more indices of handles in the
/// argument list that is ready for I/O.
///
/// If the list contains more elements than can be indexed with a `u32`
/// value, this function traps.
///
/// A timeout can be implemented by adding a pollable from the
/// wasi-clocks API to the list.
///
/// This function does not return a `result`; polling in itself does not
/// 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<pollable>) -> list<u32>

/// 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: pollable)
}
Loading

0 comments on commit b9e6b12

Please sign in to comment.