File: poll.wit

package info (click to toggle)
rust-wasmtime 26.0.1%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 48,492 kB
  • sloc: ansic: 4,003; sh: 561; javascript: 542; cpp: 254; asm: 175; ml: 96; makefile: 55
file content (47 lines) | stat: -rw-r--r-- 1,771 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package wasi:io@0.2.1;

/// A poll API intended to let users wait for I/O events on multiple handles
/// at once.
@since(version = 0.2.0)
interface poll {
    /// `pollable` represents a single I/O event which may be ready, or not.
    @since(version = 0.2.0)
    resource pollable {

      /// Return the readiness of a pollable. This function never blocks.
      ///
      /// Returns `true` when the pollable is ready, and `false` otherwise.
      @since(version = 0.2.0)
      ready: func() -> bool;

      /// `block` returns immediately if the pollable is ready, and otherwise
      /// blocks until ready.
      ///
      /// This function is equivalent to calling `poll.poll` on a list
      /// containing only this pollable.
      @since(version = 0.2.0)
      block: func();
    }

    /// 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.
    ///
    /// This function traps if either:
    /// - the list is empty, or:
    /// - the list contains more elements than can be indexed with a `u32` value.
    ///
    /// 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 ready for I/O.
    @since(version = 0.2.0)
    poll: func(in: list<borrow<pollable>>) -> list<u32>;
}