WebAssembly / wasi-io

I/O Types proposal for WASI
Other
136 stars 19 forks source link

pollable: add methods block & ready, rename poll-list to poll #54

Closed pchickey closed 10 months ago

pchickey commented 10 months ago

The name poll-one is very easily confused with poll-oneoff, the previous name of poll-list during WASI preview 1 and much of the development of Preview 2.

So, to resolve this confusion, poll-one has become the method pollable.block().

Inspecting if a poll is ready without blocking was requested in https://github.com/WebAssembly/wasi-io/issues/51. This is exposed as the method pollable.ready() -> bool.

Finally, poll-list has been renamed to poll, because there is no longer any ambiguity (relative to poll-one) about what the structure we are polling is. Personally I think it is nice to have landed in a spot where WASI poll has the same name as posix's poll(2).

The other justification for poll-list to have a distinct name was the anticipation of a future epoll-like poll-set. That future development is still available, without any compromise, by introducing some future epoll-like interface as a resource, e.g. resource poll-set { add: func(pollable, some-identifier) -> result; block() -> list<some-identifier>; ...}. But, right now we have a general consensus of YAGNI - we will get to Component Model async before we end up needing to amortize the construction of the list<borrow<pollable>> passed to poll, and that will in turn change some of the design calculus enough that it is currently premature to optimize.