On Thu, Jun 25, 2026, at 6:49 PM, Vinnie Falco wrote:
On Thu, Jun 25, 2026 at 8:57 AM Seth via Boost <boost@lists.boost.org> wrote:
I do not think that the stated requirements on a completion handler imply the Capy simple invariant as stated plainly. ... https://godbolt.org/z/r17Kxbrdr
Ha! Nice one :) Let's pick it apart:
co_await post(bind_executor(strand, deferred))
This isn't a plain awaitable being co_awaited. You are using deferred to hop executors.
Not really. Deferred is merely the default completion token. The only "hack" here is using `post` itself as a noop async operation. It was a standin but you can use *any* async operation. This is equivalent, no mention of `deferred` or `post`: https://godbolt.org/z/jh7Mf95xK (interestingly, this time it actually completed on Compiler Explorer)
On the surface it looks like what you said.
It *is* what I said: the coro resumes on another thread. Hence, the Asio requirements quoted by you do NOT ipse facto support the Capy "simple invariant" you claimed rests on it. This weakens the claim that Capy merely takes the invariants honed by 24 years of Asio evolution.
But look at what's actually happening here, the coroutine's execution context is broken down, moved into a completion handler, and then it is submitted to the bound executor, the strand. That's not a lightweight "executor switch." That is launching new work on the strand that coincidentally is "resume an existing coroutine."
Efficiency is irrelevant to the executor invariant being discussed. (As an aside, I have not observed notable allocation overhead, but maybe you're right about the "heavy" implementation of `await_transform`. At the very least the coro frame remains stable).
Capy does not come with a mechanism to change executors in the middle of the coroutine, and this is on purpose. It leads to code that is complicated and difficult to reason about. We prefer that the unit of execution is the coroutine, not a scope within a larger function.
Nothing stops you from implementing this machinery yourself of course. Okay. I'll take your word for it. It sounded a bit as if Rainer ran into trouble doing similar things. Maybe Rainer can judge whether this is substantially different.
My $0.02, Seth