Signal non UI thread

81 views
Skip to first unread message

Sarang Karandikar

unread,
Feb 11, 2021, 3:04:20 AM2/11/21
to emscripte...@googlegroups.com
Hi team,

What is the best way (API) to signal a non-UI thread in emscripten?

Thanks,
Sarang.

Sam Clegg

unread,
Feb 15, 2021, 5:49:28 PM2/15/21
to emscripte...@googlegroups.com
On Thu, Feb 11, 2021 at 12:04 AM Sarang Karandikar <sarangka...@gmail.com> wrote:
Hi team,

What is the best way (API) to signal a non-UI thread in emscripten?

The easiest way is probably to use the same techniques you would use on a native platform: communicate through shared memory and use the low level pthread APIs such as pthread_cond_signal/wait APIs  

Alternatively you could use the APIs in `emscripten/threading.h` that handle running code on another thread.  e.g.  emscripten_dispatch_to_thread (there are built on shared memory and pthreads under the hood so its fundamentally the same mechanism).

Finally, if you have a workers that yield to the JS event loop you could try to use JavaScripts postMessage rather than shared memory to communicate.  However the postMessage channel is currently managed my emscripten itself so I'm not sure how easy it would be to hook into that mechanism.  

cheers,
sam

Thanks,
Sarang.

--
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-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/CAHqdETyQ7VehPxEzTFqkKOZ_HrVqZoOefX%3DVnTqtq163xqnm9A%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages