executor affinity for ALL awaitables
I've been working on robust C++20 coroutine support in beast2 and I ran up against the "executor affinity" problem: making sure that tasks resume in the right context when they await another coroutine that might switch the context. I found there is some prior art (P3552R3) yet I am deeply unsatisfied to see it only works with senders. I came up with a general solution but I am a coroutine noob and it is hard to imagine that I can possibly be correct. I would like to know if there is a defect in my paper.
Simplifying P3552R3 with make_affine
This paper proposes make\_affine as a new reusable component for P3552R3, complementing the existing as\_awaitable and with\_awaitable\_senders building blocks. Unlike the sender-constrained affine\_on algorithm, make\_affine provides scheduler affinity for any awaitable, not just senders. This extends P3552R3's design philosophy of reusable components to cover the entire awaitable ecosystem.
https://github.com/vinniefalco/make\_affine/blob/master/p-make-affine.md
Yes I know that P3552R3 is already accepted yet I'd still like to know if I have a defect. Working code is also in the repo:
https://github.com/vinniefalco/make\_affine
Thanks
https://redd.it/1pzmei3
@r_cpp
Post #24595
30