Skip to content

[C#] Add cancel support for futures and streams#1580

Open
yowl wants to merge 1 commit intobytecodealliance:mainfrom
yowl:csharp-cancel-read
Open

[C#] Add cancel support for futures and streams#1580
yowl wants to merge 1 commit intobytecodealliance:mainfrom
yowl:csharp-cancel-read

Conversation

@yowl
Copy link
Copy Markdown
Collaborator

@yowl yowl commented Apr 4, 2026

This PR adds some support for canceling futures and streams..While dotnet Task are cancelable via tokens, that is not the design we want for components, so in this PR there is introduced a ComponentTask which is a merging of a Task and a TaskCompletionSource (and their generic counterparts) which adds a Cancel method.

In place of Rust's Result<> this uses a ComponentTask Result together with a CancelCode enum.
LiftingTaskCompletionSource is a placeholder for returning values from async functions. It requires the lifting code, but hopefully can be used as a starting point.

Changes all task continuations to be ExecuteSynchronously as we only have one thread, and this is more predicable. This should be removed if we get true multithreading.

The index suffix on imports is now created sequentially, no longer hard coded to 0.

Adds the runtime test, future-cancel-read

Clear up some debug
use same package location for codegen and runtime tests.
@yowl yowl force-pushed the csharp-cancel-read branch from 0dee73b to a87cb70 Compare April 6, 2026 00:55
@yowl yowl marked this pull request as ready for review April 6, 2026 01:04
@yowl yowl requested review from dicej and silesmo April 6, 2026 01:04
@yowl yowl changed the title WIP Csharp cancel read [C#] Add cancel support for futures and streams Apr 6, 2026
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.

1 participant