diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2021-07-14 14:19:33 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2021-07-15 15:06:53 +0000 |
commit | 8ffede6543e0f4aa528a9c87273c3daf85e10f52 (patch) | |
tree | bb88f8c2708fe5cf3a69c5cf2df5c31a2f6d69a6 /src/testlib/qtestcase.cpp | |
parent | 19f522c74aa756401de59ceb202b1338660d2be9 (diff) |
Tidy up qtestcase.cpp's WatchDog
It now uses QtPrivate::condition_variable, it pulls in the correct
header for that, so #include <condition_variable> is no longer needed.
Separate opening braces of function bodies onto next line.
Change-Id: I08f721c4d52756932bb9409e34e51dcbb3eda104
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/testlib/qtestcase.cpp')
-rw-r--r-- | src/testlib/qtestcase.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
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 <cmath> #include <numeric> #include <algorithm> -#include <condition_variable> #include <mutex> #include <chrono> @@ -1023,7 +1022,8 @@ class WatchDog : public QThread ThreadEnd, }; - bool waitFor(std::unique_lock<QtPrivate::mutex> &m, Expectation e) { + bool waitFor(std::unique_lock<QtPrivate::mutex> &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(); |