Skip to content

✨ Support awaiting futures across different contexts#94

Merged
kammce merged 1 commit intomainfrom
cross-context-awaiting
Apr 20, 2026
Merged

✨ Support awaiting futures across different contexts#94
kammce merged 1 commit intomainfrom
cross-context-awaiting

Conversation

@kammce
Copy link
Copy Markdown
Member

@kammce kammce commented Apr 20, 2026

Summary

Allow coroutines running on one context to await futures created on another context. While awaiting, the consuming context delegates its state and sleep time to the producer context, enabling proper scheduler behavior across context boundaries.

When the producer completes, the consumer resumes and receives the value, with all memory properly cleaned up. This enables more flexible async patterns where work can be distributed across multiple execution contexts.

Note that is is an anti-pattern and not a desirable usage of async context. This change fills a hole that would otherwise be UB into something with clear semantics.

Includes comprehensive tests covering normal completion, exception propagation, cancellation, and state delegation across contexts.

Related Issue

Resolves #93

Test Plan

  • All CI checks pass
  • New/updated tests cover the changes
  • Tested locally with conan create .

Allow coroutines running on one context to await futures created on
another context. While awaiting, the consuming context delegates its
state and sleep time to the producer context, enabling proper scheduler
behavior across context boundaries.

When the producer completes, the consumer resumes and receives the
value, with all memory properly cleaned up. This enables more flexible
async patterns where work can be distributed across multiple execution
contexts.

Note that is is an anti-pattern and not a desirable usage of async
context. This change fills a hole that would otherwise be UB into
something with clear semantics.

Includes comprehensive tests covering normal completion, exception
propagation, cancellation, and state delegation across contexts.

Resolves #93
@kammce kammce merged commit aacd328 into main Apr 20, 2026
7 of 8 checks passed
@kammce kammce deleted the cross-context-awaiting branch April 20, 2026 04:05
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.

Support awaiting futures across different contexts

1 participant