You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix misues of is_main_runtime_thread over is_main_browser_thread (emscripten-core#15503)
In all these places the code is really attempting to figure out if it is
the main runtime thread. i.e. the first place the program is loaded and
the place that runs the callback and async events send from secondary
threads.
The reason this mistake often goes unnoticed is that in almost all cases
the main runtime thread is also running on the main browser thread.
One easy way to see that `is_main_browser_thread` is the wrong question
to be asking in many of these cases is to remember that when emscripten
is started in a worker there is no main browser involved and so this
function will return false on *all* threads.
In the cast of `__timedwait.c` and `pthread_barrier_wait.c` the desire
is to avoid blocking the main runtime threads so that calls from other
threads can be processed by `emscripten_main_thread_process_queued_calls`.
`emscripten_main_thread_process_queued_calls` is expected to always run
on the main runtime thread, and not necessarily on the main browser
thread. Indeed its first line is:
`assert(emscripten_is_main_runtime_thread());`
0 commit comments