From 8ffede6543e0f4aa528a9c87273c3daf85e10f52 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 14 Jul 2021 14:19:33 +0200 Subject: Tidy up qtestcase.cpp's WatchDog It now uses QtPrivate::condition_variable, it pulls in the correct header for that, so #include is no longer needed. Separate opening braces of function bodies onto next line. Change-Id: I08f721c4d52756932bb9409e34e51dcbb3eda104 Reviewed-by: Marc Mutz --- src/testlib/qtestcase.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/testlib/qtestcase.cpp') diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 63c6ef92af..e42c776353 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -85,7 +85,6 @@ #include #include #include -#include #include #include @@ -1023,7 +1022,8 @@ class WatchDog : public QThread ThreadEnd, }; - bool waitFor(std::unique_lock &m, Expectation e) { + bool waitFor(std::unique_lock &m, Expectation e) + { auto expectationChanged = [this, e] { return expecting.load(std::memory_order_relaxed) != e; }; switch (e) { case TestFunctionEnd: @@ -1047,7 +1047,9 @@ public: start(); waitFor(locker, ThreadStart); } - ~WatchDog() { + + ~WatchDog() + { { const auto locker = qt_scoped_lock(mutex); expecting.store(ThreadEnd, std::memory_order_relaxed); @@ -1056,19 +1058,22 @@ public: wait(); } - void beginTest() { + void beginTest() + { const auto locker = qt_scoped_lock(mutex); expecting.store(TestFunctionEnd, std::memory_order_relaxed); waitCondition.notify_all(); } - void testFinished() { + void testFinished() + { const auto locker = qt_scoped_lock(mutex); expecting.store(TestFunctionStart, std::memory_order_relaxed); waitCondition.notify_all(); } - void run() override { + void run() override + { auto locker = qt_unique_lock(mutex); expecting.store(TestFunctionStart, std::memory_order_release); waitCondition.notify_all(); -- cgit v1.2.3