summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorStephan Bergmann <stephan.bergmann@allotropia.de>2025-02-18 11:24:43 +0100
committerStephan Bergmann <stephan.bergmann@allotropia.de>2025-02-19 23:25:42 +0100
commit5e1973754a9b924b2d9362c6083866d2cf93b790 (patch)
tree4a246013b70f6a02b8c20e623ff61b2a01b4fafb /vcl
parent4d580ab25c24fc2293f41a3b580c874f817ee7aa (diff)
Redesign comphelper::emscriptenthreading::Data::eventHandlerThread
Instead of being a thread that keeps blocking in C++ emscripten::ProxyingQueue::execute(), make it a thread that immediately goes back to the browser event loop via emscripten_exit_with_live_runtime(). (Which will eventually allow setupMainChannel from desktop/source/app/appinit.cxx to run on that thread and receive the "LOWA-channel" JS message event.) The thread is detached now and no longer joined in comphelper::emscriptenthreading::tearDown, but that was mostly academic anyway (as LOWA doesn't terminate in the traditional sense, and just stops when you close its browser tab). Change-Id: I32270cfc602549cf26b99c6f66811b3aca5ea5c0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181907 Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de> Tested-by: Jenkins
Diffstat (limited to 'vcl')
-rw-r--r--vcl/qt5/QtInstance.cxx6
-rw-r--r--vcl/source/app/scheduler.cxx12
2 files changed, 11 insertions, 7 deletions
diff --git a/vcl/qt5/QtInstance.cxx b/vcl/qt5/QtInstance.cxx
index fc20ecc9e11c..34a589bd4a57 100644
--- a/vcl/qt5/QtInstance.cxx
+++ b/vcl/qt5/QtInstance.cxx
@@ -207,7 +207,7 @@ void QtInstance::RunInMainThread(std::function<void()> func)
return;
}
#if defined EMSCRIPTEN && ENABLE_QT6 && HAVE_EMSCRIPTEN_JSPI && !HAVE_EMSCRIPTEN_PROXY_TO_PTHREAD
- if (pthread_self() == m_emscriptenThreadingData->eventHandlerThread.native_handle())
+ if (pthread_self() == m_emscriptenThreadingData->eventHandlerThread)
{
EmscriptenLightweightRunInMainThread(func);
return;
@@ -492,7 +492,7 @@ bool QtInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents)
m_aWaitingYieldCond.set();
}
#if defined EMSCRIPTEN && ENABLE_QT6 && HAVE_EMSCRIPTEN_JSPI && !HAVE_EMSCRIPTEN_PROXY_TO_PTHREAD
- else if (pthread_self() == m_emscriptenThreadingData->eventHandlerThread.native_handle())
+ else if (pthread_self() == m_emscriptenThreadingData->eventHandlerThread)
{
SolarMutexReleaser release;
struct Args
@@ -563,7 +563,7 @@ void QtInstance::ProcessEvent(SalUserEvent aEvent)
SolarMutexReleaser release;
(void)emscripten_promise_await(
emscripten_proxy_promise(m_emscriptenThreadingData->proxyingQueue.queue,
- m_emscriptenThreadingData->eventHandlerThread.native_handle(),
+ m_emscriptenThreadingData->eventHandlerThread,
[](void* p) {
auto& aEvent = *static_cast<SalUserEvent*>(p);
SolarMutexGuard g;
diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx
index ae88dee55df2..2dcc14fe1988 100644
--- a/vcl/source/app/scheduler.cxx
+++ b/vcl/source/app/scheduler.cxx
@@ -559,10 +559,14 @@ void Scheduler::CallbackTaskScheduling()
if (pTask->DecideTransferredExecution())
{
auto & data = comphelper::emscriptenthreading::getData();
- data.proxyingQueue.proxyAsync(data.eventHandlerThread.native_handle(), [pTask] {
- SolarMutexGuard g;
- pTask->Invoke();
- });
+ (void) emscripten_proxy_promise(
+ data.proxyingQueue.queue, data.eventHandlerThread,
+ [](void * p) {
+ auto const pTask = static_cast<Task *>(p);
+ SolarMutexGuard g;
+ pTask->Invoke();
+ },
+ pTask);
}
else
{