Skip to content

Replace 'sync' with 'cancellable' in wait/poll/yield #548

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 30, 2025
Merged

Conversation

lukewagner
Copy link
Member

This PR offers a better solution to the issue described in #546 (in which dependency code doesn't want to receive cancellation events it doesn't know what to do with). Instead of coupling "cancellable" to "async", this PR splits them into two separate immediates, replacing the optional async immediate on yield/wait/poll with cancellable. Since this immediate was not included in the 0.3.0 release, but rather as part of a later 🚟 stackful async release, this shouldn't require any change to 0.3.0 implementations (other than perhaps s/async/cancellable/ in not-yet-implemented validation errors).

A more subtle change in this PR that also doesn't change observable behavior in 0.3.0, but does for the later 🚟 stackful async release, is that synchronous builtins and canon lower no longer have "suspend the component instance" semantics. Instead, the desired "non-reentrancy of sync and async callback core wasm code" invariant is achieved far more directly as part of the semantics of canon lift.

Some advantages of these changes (in the stackful async / cooperative threads timeframe):

  • The synchronous and async ABI options are no longer overloaded and decoupled from (1) cancellability, (2) serialization.
  • We can over time add cancellable to more built-ins and even canon lower for both sync and async, allowing cancellation to be delivered promptly in more cases.
  • Cooperative threads will work just like stackful async exports in that they avoid the non-reentrancy locking entirely, progressing at their own (cooperative) pace, relying on the producer toolchain to handle multiple linear memory stacks etc.

Replace instance-suspension semantics of sync lower with instance-locking semantics in lift
@lukewagner lukewagner merged commit f22dc1f into main Jul 30, 2025
2 checks passed
@lukewagner lukewagner deleted the cancellable branch July 30, 2025 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants