On Wed, Nov 14, 2018 at 5:19 PM Gavin Lambert via Boost < boost@lists.boost.org> wrote:
On 15/11/2018 12:29, Emil Dotchevski wrote:
It uses thread_local raw pointers, one per error type. This is needed in order to decouple result<T> from the static type of error objects being propagated, which I consider critical, see https://zajo.github.io/leaf/#rationale.
Is it compatible with coroutines or fibers or other non-thread-based stacks?
Good question. I'm not sure, but I'm interested to know what are the issues.
In general AFAIK, any use of thread-local storage is entirely incompatible with coroutines or fibers. (Unless the mechanisms for both cooperate with each other, which is theoretically possible but I'm not aware of it occurring in the wild.)
The LEAF machinery that is used for multi-thread support can probably be used as-is for coroutines as well. It should be possible to explicitly support coroutines context switching, which would be much faster, involving only setting raw pointers, possibly exactly one raw pointer.