Skip to content

async: add shared_awaitable<T> — multi-consumer broadcast awaitable (…#325

Merged
szmyd merged 1 commit into
eBay:dev/v14.xfrom
szmyd:dev/v14.x
Jun 4, 2026
Merged

async: add shared_awaitable<T> — multi-consumer broadcast awaitable (…#325
szmyd merged 1 commit into
eBay:dev/v14.xfrom
szmyd:dev/v14.x

Conversation

@szmyd

@szmyd szmyd commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

…folly::SharedPromise replacement)

value_awaitable resumes one waiter and moves its result out (single-shot); shared_awaitable resumes ALL installed waiters and hands each a copy (broadcast), so T must be copyable. It is the coroutine-native replacement for folly::SharedPromise — the pattern where several callers await one in-flight completion (e.g. N threads triggering one checkpoint flush). Single-mutex handshake, resumes performed outside the lock so a resumed coroutine may re-enter; no lost wakeup on the await_suspend/complete race; idempotent complete().

Header-only, stdexec-free. test_shared_awaitable covers both completion orderings, the broadcast (N waiters, one complete), idempotent second complete, copyable-payload sharing, refcounted-state survival, and a TSAN-friendly cross-thread broadcast race (1000 iters x 4 waiter threads + completer).

…folly::SharedPromise replacement)

value_awaitable resumes one waiter and moves its result out (single-shot); shared_awaitable resumes ALL
installed waiters and hands each a copy (broadcast), so T must be copyable. It is the coroutine-native
replacement for folly::SharedPromise<T> — the pattern where several callers await one in-flight completion
(e.g. N threads triggering one checkpoint flush). Single-mutex handshake, resumes performed outside the lock
so a resumed coroutine may re-enter; no lost wakeup on the await_suspend/complete race; idempotent complete().

Header-only, stdexec-free. test_shared_awaitable covers both completion orderings, the broadcast (N waiters,
one complete), idempotent second complete, copyable-payload sharing, refcounted-state survival, and a
TSAN-friendly cross-thread broadcast race (1000 iters x 4 waiter threads + completer).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@szmyd szmyd merged commit 943e2fe into eBay:dev/v14.x Jun 4, 2026
5 checks passed
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