WebAssembly / WebAssembly/component-model
Non-blocking I/O without cancellation
Nobody has claimed this yet.
- Dominant language
- WebAssembly
- Stars
- 1.4k
- Forks
- 130
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 15
Description
Hi! The concurrency explainer contains an example on how to implement non-blocking IO.
write()callsstream.write, forwarding the caller's buffer.- If
stream.writereturns that it successfully copied some bytes without
blocking,write()returns success.- Otherwise, to avoid blocking:
write()calls [stream.cancel-write] to regain ownership of the
caller's buffer.- If
select()has not indicated that this file descriptor is ready,
write()starts a zero-length write and returnsEWOULDBLOCK.- Otherwise, to avoid the potential infinite loop:
write()copies the contents of the caller's buffer into an
internal buffer, starts a newstream.writeto complete in the
background using the internal buffer, and then returns success.- The above logic implicitly waits for this background
stream.write
to complete before the file descriptor is considered ready again.
But it also says:
Cancellation is cooperative, (...) allowing the subtask to continue executing for an arbitrary amount of time
Is there a contradiction here?
If the other end of a stream doesn't respect cancellation immediately (which is allowed) or doesn't support cancellation at all (also allowed) the guest will still end up being blocked.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read design/mvp/Concurrency.md sections "stream-readiness" and "cancellation" first, then compare the non-blocking I/O example with the stated cooperative-cancellation behavior. Determine whether the two descriptions are consistent and, if not, identify what clarification the explainer needs; completion requires a maintainer-approved resolution in the documentation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- wasm
- Domain
- operating-systems
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100