On Mon, Feb 14, 2022 at 6:28 PM Gavin Lambert via Boost < boost@lists.boost.org> wrote:
On 15/02/2022 15:11, Emil Dotchevski wrote:
In terms of the latter, Gavin quite literally describes Boost LEAF. It
is
indeed possible for "Boost-aware" throws to automatically detect what info is actually needed for error handling, and only spend cycles capturing that. This is exactly how leaf::on_error works.
Not quite. LEAF works explicitly through TLS rather than the local stack, which makes it less compatible with coroutines, AFAIK.
Are exceptions compatible with coroutines? Exception handling does use TLS.
Granted that the mechanism I proposed would probably not be implementable without a TLS root to register with or something; while the context objects themselves would naturally be coroutine-compatible, a way to actually *find* which ones are still in scope in a particular context is harder to manage without making those sorts of assumptions.
This can work to exactly the same extent it can be implemented in LEAF. To make it compatible with coroutines, the leaf::context object (which contains the error info objects) just needs to be deactivate()d in one thread, then activate()d in the new thread (which points TLS pointers to its contents).