Hi Paolo, > > Emscripten's fiber does not support submitting coroutines to other > > threads. > > Does it work as long as the thread does not rewind?
The structure used by Fiber includes a thread-specific field related to rewind [1], which prevents it from being shared across threads. The behavior of the remaining fields in multi-threaded contexts is not documented, so further experimentation is needed to determine whether they can be safely shared. [1] https://emscripten.org/docs/api_reference/fiber.h.html#c.asyncify_data_t.rewind_id > You can add all these to the stubs/emscripten.c file that I suggested > elsewhere. Sure, I'll apply this reorganization in the next verison of the series. > You could extracting v9fs_co_run_in_worker()'s bodies into separate > functions. It is tedious but not hard; all you have to do is define > structs for the to parameters and return values of v9fs_co_*(), unpack > them in the callback functions, and retrieve the return value in > v9fs_co_*(). Many functions > > The advantage is that, instead of all the bottom half and yielding dance > that is done by v9fs_co_run_in_worker() and co_run_in_worker_bh(), you > can just use thread_pool_submit_co(). Thank you for the suggestion. I'll explore this approach, though it's still unclear whether thread_pool_submit_co() can be used with Emscripten's Fiber due to the limitations mentioned above.