diff options
author | Maurice Kalinowski <maurice.kalinowski@theqtcompany.com> | 2015-12-09 12:23:38 +0100 |
---|---|---|
committer | Maurice Kalinowski <maurice.kalinowski@theqtcompany.com> | 2015-12-14 08:43:31 +0000 |
commit | 7f92edb7ac55bc27de25a2274e2d2435d8aaab49 (patch) | |
tree | 0aa798a2cacd52f4cb0a6d77a6f3f466641fa9ca /src | |
parent | 127b9fa5b0d6dfdf666b1e6593b848ae33556020 (diff) |
winrt: Avoid blocking for the first processEvents run
When calling WaitForMultipleObjectsEx, do not use a
timeout for the initial call. This saves around 10%
of blocking invocations in the QEventLoop autotests.
Change-Id: Ib24436ed11de1865e31f9ff0ddf6ce1bc5562f42
Reviewed-by: Andrew Knight <andrew.knight@intopalo.com>
Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/kernel/qeventdispatcher_winrt.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/corelib/kernel/qeventdispatcher_winrt.cpp b/src/corelib/kernel/qeventdispatcher_winrt.cpp index 58b87bd36b..df070dd1ae 100644 --- a/src/corelib/kernel/qeventdispatcher_winrt.cpp +++ b/src/corelib/kernel/qeventdispatcher_winrt.cpp @@ -201,14 +201,16 @@ bool QEventDispatcherWinRT::processEvents(QEventLoop::ProcessEventsFlags flags) { Q_D(QEventDispatcherWinRT); + DWORD waitTime = 0; do { // Additional user events have to be handled before timer events, but the function may not // return yet. const bool userEventsSent = sendPostedEvents(flags); - emit aboutToBlock(); const QVector<HANDLE> timerHandles = d->timerIdToHandle.values().toVector(); - DWORD waitResult = WaitForMultipleObjectsEx(timerHandles.count(), timerHandles.constData(), FALSE, 1, TRUE); + if (waitTime) + emit aboutToBlock(); + DWORD waitResult = WaitForMultipleObjectsEx(timerHandles.count(), timerHandles.constData(), FALSE, waitTime, TRUE); if (waitResult >= WAIT_OBJECT_0 && waitResult < WAIT_OBJECT_0 + timerHandles.count()) { const HANDLE handle = timerHandles.value(waitResult - WAIT_OBJECT_0); ResetEvent(handle); @@ -231,6 +233,13 @@ bool QEventDispatcherWinRT::processEvents(QEventLoop::ProcessEventsFlags flags) if (userEventsSent) return true; + + // We cannot wait infinitely like on other platforms, as + // WaitForMultipleObjectsEx might not return. + // For instance win32 uses MsgWaitForMultipleObjects to hook + // into the native event loop, while WinRT handles those + // via callbacks. + waitTime = 1; } while (flags & QEventLoop::WaitForMoreEvents); return false; } |