Emscripten fiber backend declares three variables as plain static:
|
static emscripten_fiber_t* running_fib = NULL; |
|
static unsigned char main_asyncify_stack[MCO_ASYNCFY_STACK_SIZE]; |
|
static emscripten_fiber_t main_fib; |
Without thread_local, all threads share the same instance, so any concurrent fiber usage curropts them.
Emscripten fiber API is designed for per-thread usage - emscripten_fiber_init_from_current_context is documented as capturing "the thread's original context" fiber.h docs, implying each thread is expected to maintain its own fiber context. The fix is straightforward:
static thread_local emscripten_fiber_t* running_fib = NULL;
static thread_local unsigned char main_asyncify_stack[MCO_ASYNCFY_STACK_SIZE];
static thread_local emscripten_fiber_t main_fib;
This fix would allow us to run independent fibers on threads, with limitation that each fiber is pinned to thread that it was started on (can not be resumed on other thread).
Emscripten fiber backend declares three variables as plain
static:minicoro/minicoro.h
Lines 1483 to 1485 in 02dad0f
Without
thread_local, all threads share the same instance, so any concurrent fiber usage curropts them.Emscripten fiber API is designed for per-thread usage -
emscripten_fiber_init_from_current_contextis documented as capturing "the thread's original context" fiber.h docs, implying each thread is expected to maintain its own fiber context. The fix is straightforward:This fix would allow us to run independent fibers on threads, with limitation that each fiber is pinned to thread that it was started on (can not be resumed on other thread).