Skip to content

feat: interrupt remaining tasks on failure in map() and asMap()#24

Draft
praveer-rai wants to merge 3 commits intomainfrom
feat/cancel-on-failure
Draft

feat: interrupt remaining tasks on failure in map() and asMap()#24
praveer-rai wants to merge 3 commits intomainfrom
feat/cancel-on-failure

Conversation

@praveer-rai
Copy link
Copy Markdown
Contributor

Summary

When a task fails in map() or asMap(), remaining virtual threads are now interrupted instead of left running in the background. This matches StructuredTaskScope semantics — fail fast and clean up.

toEither and toEitherMap are unchanged — their contract is to run all tasks to completion and collect per-item results.

Internally, introduces a package-private Blockless.AsyncTask record that exposes the thread handle alongside the result supplier, enabling Parallel to interrupt threads on failure without changing any public API.

Test plan

  • map() interrupts remaining tasks when one fails
  • asMap() interrupts remaining tasks when one fails
  • toEither still runs all tasks to completion (no cancellation)
  • All existing tests pass unchanged
  • README updated

When a task fails, remaining virtual threads are now interrupted instead
of left running in the background. This matches StructuredTaskScope
semantics — fail fast and clean up. toEither/toEitherMap are unchanged
since their contract is to run all tasks to completion.
@praveer-rai praveer-rai marked this pull request as draft April 22, 2026 20:28
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