diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2025-01-10 16:19:10 +0500 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2025-01-10 14:12:52 +0100 |
commit | 6b6f8ca3dd4aa145519f5961f822435607d0e1d1 (patch) | |
tree | f242f7b0db5f1bca6810a25bc58b199d444da34c /sal | |
parent | 0dfecee85589abfb94d9fa0cc8129c4fdbaf696c (diff) |
Factor out and simplify COM-safe wait
Before commit 1e2e51607a163021ef1fb1fb0d217266bd448173 (Try to use
CoWaitForMultipleHandles magic to handle COM message loop, 2025-01-10)
osl_waitCondition didn't adjust the timeout value in the COM message
processing loop. The abovementioned commit started to use a function
that pumps the message loop itself, but the code for manual pumping
wasn't removed (it has (likely) became dead).
This drops the dead code, and deduplicates the rest.
Change-Id: I0f7bbf8220792fbe42178c2689a065b5f38645d6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180069
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sal')
-rw-r--r-- | sal/osl/w32/conditn.cxx | 39 |
1 files changed, 9 insertions, 30 deletions
diff --git a/sal/osl/w32/conditn.cxx b/sal/osl/w32/conditn.cxx index 0ad233ed9bff..9063899533c3 100644 --- a/sal/osl/w32/conditn.cxx +++ b/sal/osl/w32/conditn.cxx @@ -22,6 +22,7 @@ #include <osl/conditn.h> #include <osl/diagnose.h> #include <osl/time.h> +#include <systools/win32/wait_for_multiple_objects.hxx> /* under WIN32, we use the void* oslCondition @@ -75,39 +76,17 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, /* It's necessary to process SendMessage calls to the current thread to give other threads access to COM objects instantiated in this thread */ - - while ( true ) + switch (sal::systools::WaitForMultipleObjects_COMDispatch( + 1, reinterpret_cast<HANDLE*>(&Condition), timeout)) { - DWORD index; - /* Only wake up if a SendMessage / COM call to the threads message loop is detected */ - HRESULT hr = CoWaitForMultipleHandles(COWAIT_DISPATCH_CALLS, timeout, 1, - reinterpret_cast<HANDLE*>(&Condition), &index); - if (hr == RPC_S_CALLPENDING) - return osl_cond_result_timeout; - if (FAILED(hr)) - return osl_cond_result_error; - switch (index) - { - case WAIT_OBJECT_0 + 1: - { - MSG msg; - - /* We Must not dispatch the message. PM_NOREMOVE leaves the message queue untouched - but dispatches SendMessage calls automatically */ + case WAIT_OBJECT_0: + return osl_cond_result_ok; - PeekMessageW( &msg, nullptr, 0, 0, PM_NOREMOVE ); - } - break; - - case WAIT_OBJECT_0: - return osl_cond_result_ok; - - case WAIT_TIMEOUT: - return osl_cond_result_timeout; + case WAIT_TIMEOUT: + return osl_cond_result_timeout; - default: - return osl_cond_result_error; - } + default: + return osl_cond_result_error; } } |