Skip to content

Commit 89da966

Browse files
committed
Replace coroutine_handle with continuation in executor interface
The executor concept's dispatch() and post() now accept continuation& instead of std::coroutine_handle<>. A continuation wraps a coroutine handle with an intrusive next_ pointer, enabling executors to queue work without per-post heap allocation. The thread pool's post() previously allocated a work node on every call (new work(h)). It now links the caller's continuation directly into an intrusive queue — zero allocation on the hot path. The continuation lives in the I/O awaitable for caller-handle posting (delay, async_mutex, async_event, stream), and in combinator/trampoline state for parent-dispatch and child-launch patterns (when_all, when_any, timeout, run, run_async). The IoAwaitable concept and io_awaitable_promise_base are unchanged. Breaking change: all Executor implementations must update dispatch() and post() signatures from coroutine_handle<> to continuation&.
1 parent 150ee20 commit 89da966

40 files changed

+1127
-450
lines changed

bench/bench.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,14 @@ class bench_io_context::executor_type
8181
{
8282
}
8383

84-
std::coroutine_handle<> dispatch(std::coroutine_handle<> h) const
84+
std::coroutine_handle<> dispatch(continuation& c) const
8585
{
86-
return h;
86+
return c.h;
8787
}
8888

89-
void post(std::coroutine_handle<> h) const
89+
void post(continuation& c) const
9090
{
91-
h.resume();
91+
c.h.resume();
9292
}
9393

9494
void defer(std::coroutine_handle<> h) const

0 commit comments

Comments
 (0)