Skip to content

Conversation

@tzcnt
Copy link
Owner

@tzcnt tzcnt commented Feb 3, 2026

Previously tmc::fork_group was an rvalue-only awaitable, like most other TMC awaitables. This restriction makes sense for awaitables that initiate work and retrieve results in the same operation (since initiating work is not idempotent). However, fork_group separates the steps of initiating work and awaiting it. So we can make it an lvalue awaitable which can be awaited multiple times to retrieve the same result again. Or the user can still cast to rvalue to move-from the result. If the user wants to dispatch another group of work later, they can call reset() before doing so.

This allows it to replace tmc::manual_reset_event in some places, with a caveat: awaiting manual_reset_event is thread-safe as it has a mechanism to register multiple awaiters, but fork_group does not. So only a single thread should await fork_group at any given time.

Supported usages:
co_await fg; // returns ResultArray&
co_await std::move(fg); // returns ResultArray&&
std::move(co_await fg); // returns ResultArray&&

@tzcnt tzcnt changed the title make fork_group awaitable multiple times fork_group can be awaited multiple times Feb 3, 2026
@tzcnt tzcnt changed the title fork_group can be awaited multiple times tmc::fork_group can be awaited multiple times Feb 3, 2026
@tzcnt tzcnt force-pushed the fork_group_reusable branch from 508ba62 to f6d0088 Compare February 3, 2026 06:20
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