On Thu, Feb 11, 2021 at 12:04 AM Sarang Karandikar <
[email protected]> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/emscripten-discuss/CAHqdETyQ7VehPxEzTFqkKOZ_HrVqZoOefX%3DVnTqtq163xqnm9A%40mail.gmail.com
> <https://groups.google.com/d/msgid/emscripten-discuss/CAHqdETyQ7VehPxEzTFqkKOZ_HrVqZoOefX%3DVnTqtq163xqnm9A%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/emscripten-discuss/CAL_va29XqhkAoOsmXrJEx2PHNDuoL7cSq2R8hH8mZP3HQdd9wQ%40mail.gmail.com.
  • Signal non UI thread Sarang Karandikar
    • Re: Signal non UI thread 'Sam Clegg' via emscripten-discuss

Reply via email to