On 15/02/2022 15:46, Emil Dotchevski wrote:
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.
Exceptions propagate back through the coroutine to its consumer via entirely compiler-generated code (or equivalent library code for pre-C++20 coroutines), somewhat like (but not identical to) futures.
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).
Where would you put such calls? How would you know which ones to call?