diff options
author | Johan Klokkhammer Helsing <johan.helsing@qt.io> | 2016-07-29 15:46:25 +0200 |
---|---|---|
committer | Johan Helsing <johan.helsing@qt.io> | 2016-08-02 07:11:15 +0000 |
commit | 798127e5c9a107ddd8cc1c04495ce39b64513bdb (patch) | |
tree | e4364c6a76332ecd31780b0ecf40e2abb9049d9c | |
parent | aefdb7652085afbd84d089d86dfc7d7e642a097d (diff) | |
download | qtwayland-798127e5c9a107ddd8cc1c04495ce39b64513bdb.tar.gz |
Client tests: Unlock mutex while processing compositor commands
Only lock the client autotest compositor mutex when necessary. This allows
compositor commands to be queued while a command is being processed.
Change-Id: Ib2ca6b4942f57f56f56a055cbe6ce6d876695529
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
-rw-r--r-- | tests/auto/client/mockcompositor.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/tests/auto/client/mockcompositor.cpp b/tests/auto/client/mockcompositor.cpp index 68245226..7eb68319 100644 --- a/tests/auto/client/mockcompositor.cpp +++ b/tests/auto/client/mockcompositor.cpp @@ -185,9 +185,16 @@ void MockCompositor::processCommand(const Command &command) void MockCompositor::dispatchCommands() { - foreach (const Command &command, m_commandQueue) + lock(); + int count = m_commandQueue.length(); + unlock(); + + for (int i = 0; i < count; ++i) { + lock(); + const Command command = m_commandQueue.takeFirst(); + unlock(); command.callback(command.target, command.parameters); - m_commandQueue.clear(); + } } void *MockCompositor::run(void *data) @@ -205,8 +212,11 @@ void *MockCompositor::run(void *data) } while (controller->m_alive) { - QMutexLocker locker(&controller->m_mutex); - controller->m_waitCondition.wait(&controller->m_mutex); + { + QMutexLocker locker(&controller->m_mutex); + if (controller->m_commandQueue.isEmpty()) + controller->m_waitCondition.wait(&controller->m_mutex); + } controller->dispatchCommands(); compositor.dispatchEvents(20); } |