|
1 | 1 | export namespace WasiPollPoll { |
2 | | - export { Pollable }; |
| 2 | + /** |
| 3 | + * Dispose of the specified `pollable`, after which it may no longer |
| 4 | + * be used. |
| 5 | + */ |
| 6 | + export function dropPollable(this_: Pollable): void; |
3 | 7 | /** |
4 | 8 | * Poll for completion on a set of pollables. |
5 | 9 | * |
6 | | - * This function takes a list of pollables, which identify I/O sources of |
7 | | - * interest, and waits until one or more of the events is ready for I/O. |
8 | | - * |
9 | | - * The result `list<bool>` is the same length as the argument |
10 | | - * `list<pollable>`, and indicates the readiness of each corresponding |
11 | | - * element in that list, with true indicating ready. A single call can |
12 | | - * return multiple true elements. |
13 | | - * |
14 | | - * A timeout can be implemented by adding a pollable from the |
15 | | - * wasi-clocks API to the list. |
16 | | - * |
17 | | - * This function does not return a `result`; polling in itself does not |
18 | | - * do any I/O so it doesn't fail. If any of the I/O sources identified by |
19 | | - * the pollables has an error, it is indicated by marking the source as |
20 | | - * ready in the `list<bool>`. |
21 | | - * |
22 | 10 | * The "oneoff" in the name refers to the fact that this function must do a |
23 | 11 | * linear scan through the entire list of subscriptions, which may be |
24 | 12 | * inefficient if the number is large and the same subscriptions are used |
25 | 13 | * many times. In the future, this is expected to be obsoleted by the |
26 | 14 | * component model async proposal, which will include a scalable waiting |
27 | 15 | * facility. |
| 16 | + * |
| 17 | + * The result list<bool> is the same length as the argument |
| 18 | + * list<pollable>, and indicates the readiness of each corresponding |
| 19 | + * element in that / list, with true indicating ready. |
28 | 20 | */ |
29 | | - export function pollOneoff(in_: Pollable[]): boolean[]; |
30 | | -} |
31 | | - |
32 | | -export class Pollable { |
33 | | - constructor(init: Uint8Array | ArrayBuffer) |
34 | | - write(bytes: Uint8Array | ArrayBuffer): void; |
35 | | - read(n: number): Uint8Array; |
36 | | - static merge(lhs: Pollable, rhs: Pollable): Pollable; |
| 21 | + export function pollOneoff(in_: Uint32Array): boolean[]; |
37 | 22 | } |
| 23 | +/** |
| 24 | + * A "pollable" handle. |
| 25 | + * |
| 26 | + * This is conceptually represents a `stream<_, _>`, or in other words, |
| 27 | + * a stream that one can wait on, repeatedly, but which does not itself |
| 28 | + * produce any data. It's temporary scaffolding until component-model's |
| 29 | + * async features are ready. |
| 30 | + * |
| 31 | + * And at present, it is a `u32` instead of being an actual handle, until |
| 32 | + * the wit-bindgen implementation of handles and resources is ready. |
| 33 | + * |
| 34 | + * `pollable` lifetimes are not automatically managed. Users must ensure |
| 35 | + * that they do not outlive the resource they reference. |
| 36 | + * |
| 37 | + * This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources). |
| 38 | + */ |
| 39 | +export type Pollable = number; |
0 commit comments