Debian Codegraph @

vendor/wit-component/tests/interfaces/wasi-http/deps/io/poll.wit

raw
1 package wasi:[email protected];
2
3 /// A poll API intended to let users wait for I/O events on multiple handles
4 /// at once.
5 interface poll {
6 /// `pollable` represents a single I/O event which may be ready, or not.
7 resource pollable {
8
9 /// Return the readiness of a pollable. This function never blocks.
10 ///
11 /// Returns `true` when the pollable is ready, and `false` otherwise.
12 ready: func() -> bool;
13
14 /// `block` returns immediately if the pollable is ready, and otherwise
15 /// blocks until ready.
16 ///
17 /// This function is equivalent to calling `poll.poll` on a list
18 /// containing only this pollable.
19 block: func();
20 }
21
22 /// Poll for completion on a set of pollables.
23 ///
24 /// This function takes a list of pollables, which identify I/O sources of
25 /// interest, and waits until one or more of the events is ready for I/O.
26 ///
27 /// The result `list<u32>` contains one or more indices of handles in the
28 /// argument list that is ready for I/O.
29 ///
30 /// If the list contains more elements than can be indexed with a `u32`
31 /// value, this function traps.
32 ///
33 /// A timeout can be implemented by adding a pollable from the
34 /// wasi-clocks API to the list.
35 ///
36 /// This function does not return a `result`; polling in itself does not
37 /// do any I/O so it doesn't fail. If any of the I/O sources identified by
38 /// the pollables has an error, it is indicated by marking the source as
39 /// being reaedy for I/O.
40 poll: func(in: list<borrow<pollable>>) -> list<u32>;
41 }