Debian Codegraph @

.cargo/vendor/wasip2/wit/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 @since(version = 0.2.0)
6 interface poll {
7 /// `pollable` represents a single I/O event which may be ready, or not.
8 @since(version = 0.2.0)
9 resource pollable {
10
11 /// Return the readiness of a pollable. This function never blocks.
12 ///
13 /// Returns `true` when the pollable is ready, and `false` otherwise.
14 @since(version = 0.2.0)
15 ready: func() -> bool;
16
17 /// `block` returns immediately if the pollable is ready, and otherwise
18 /// blocks until ready.
19 ///
20 /// This function is equivalent to calling `poll.poll` on a list
21 /// containing only this pollable.
22 @since(version = 0.2.0)
23 block: func();
24 }
25
26 /// Poll for completion on a set of pollables.
27 ///
28 /// This function takes a list of pollables, which identify I/O sources of
29 /// interest, and waits until one or more of the events is ready for I/O.
30 ///
31 /// The result `list<u32>` contains one or more indices of handles in the
32 /// argument list that is ready for I/O.
33 ///
34 /// This function traps if either:
35 /// - the list is empty, or:
36 /// - the list contains more elements than can be indexed with a `u32` value.
37 ///
38 /// A timeout can be implemented by adding a pollable from the
39 /// wasi-clocks API to the list.
40 ///
41 /// This function does not return a `result`; polling in itself does not
42 /// do any I/O so it doesn't fail. If any of the I/O sources identified by
43 /// the pollables has an error, it is indicated by marking the source as
44 /// being ready for I/O.
45 @since(version = 0.2.0)
46 poll: func(in: list<borrow<pollable>>) -> list<u32>;
47 }