I'm trying out converting a previously-emterpreted project to the 
SharedArrayBuffer and USE_PTHREADS=1.  One of the first things I tried out 
with that was MAIN_THREAD_EM_ASM().

However, ENVIRONMENT='worker', and when I use it then it still runs on the 
worker.

What I'd guess then is that "MAIN_THREAD_" refers not to the browser's UI 
thread, but rather wherever the emscripten'd code was launched ("the main() 
thread")?

Because I see it runs this:

    function _emscripten_asm_const_sync_on_main_thread_i(code) {
        if (ENVIRONMENT_IS_PTHREAD) { return 
_emscripten_sync_run_in_browser_thread_i(-1 - code); } 
        return ASM_CONSTS[code]();
    }

In the debugger I see ENVIRONMENT_IS_PTHREAD is false.  Naively setting 
ENVIRONMENT_IS_PTHREAD doesn't work.  :-)

There are a number of settings I see regarding proxying to workers or doing 
a number of other things, so I suspect what I am aiming to do is something 
that people have thought of.  I have a list of APIs in a `--post-js` file 
that I'd like to be available on *either* the GUI thread or the worker 
(though the ones that make synchronous UI requests of the browser will only 
be callable from the worker, where the stack can be doing an Atomics.wait() 
but preserved while the UI does its thing).

Should I change ENVIRONMENT='web', and perhaps start by picking some other 
flags?  Is there an example to follow?  It would be a bit of a shake-up, 
and I kind of like having the loading being done on the worker how it is 
right now.  But if that is bucking the trend of having the hard problems 
solved by someone else I can deal with changing it!

Best,
--Brian

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to emscripten-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to