From 24a3a7c72714c4f45c46cd2b6274013503d444d6 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 3 Sep 2024 09:38:58 +0200 Subject: Emscripten: workerID is only defined under -sASSERTIONS ...and explicitly passing in pthread_self() on the calling side is better than trying to identify the calling thread on the callee side, anyway Change-Id: Ib26a7cbdede246280b6985b6eb1582baf172bf59 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172786 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- desktop/source/app/appinit.cxx | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'desktop/source/app') diff --git a/desktop/source/app/appinit.cxx b/desktop/source/app/appinit.cxx index 3a8bce551d6a..16f023b0a414 100644 --- a/desktop/source/app/appinit.cxx +++ b/desktop/source/app/appinit.cxx @@ -93,20 +93,13 @@ EM_JS(void, setupMainChannel, (), { }; }); -extern "C" void resolveUnoMain() { - EM_ASM( - let sofficeMain; - for (const i in PThread.pthreads) { - const worker = PThread.pthreads[i]; - if (worker.workerID === 1) { - sofficeMain = worker; - break; - } - } +extern "C" void resolveUnoMain(pthread_t id) { + EM_ASM({ + const sofficeMain = PThread.pthreads[$0]; const channel = new MessageChannel(); sofficeMain.postMessage({cmd:"LOWA-channel"}, [channel.port2]); Module.uno_main$resolve(channel.port1); - ); + }, id); } void initUno() { @@ -120,7 +113,7 @@ void initUno() { runUnoScriptUrl(url.getStr()); } setupMainChannel(); - emscripten_async_run_in_main_runtime_thread(EM_FUNC_SIG_V, resolveUnoMain); + emscripten_async_run_in_main_runtime_thread(EM_FUNC_SIG_VI, resolveUnoMain, pthread_self()); } } -- cgit