QTest::WatchDog: Extract Method setExpectation()
Keeps the code DRY and enables a follow-up commit to fix QTBUG-109466. Task-number: QTBUG-109466 Change-Id: I2b904ea7b38286b07049524ba63c2c5028e680bb Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit 17a7e5cfddcbf33ef0fd1c2b7acc65b85159194e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
c2118a461a
commit
cf573f97fc
@ -1233,6 +1233,13 @@ class WatchDog : public QThread
|
|||||||
Q_UNREACHABLE_RETURN(false);
|
Q_UNREACHABLE_RETURN(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setExpectation(Expectation e)
|
||||||
|
{
|
||||||
|
const auto locker = qt_scoped_lock(mutex);
|
||||||
|
expecting.store(e, std::memory_order_relaxed);
|
||||||
|
waitCondition.notify_all();
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
WatchDog()
|
WatchDog()
|
||||||
{
|
{
|
||||||
@ -1245,26 +1252,18 @@ public:
|
|||||||
|
|
||||||
~WatchDog()
|
~WatchDog()
|
||||||
{
|
{
|
||||||
{
|
setExpectation(ThreadEnd);
|
||||||
const auto locker = qt_scoped_lock(mutex);
|
|
||||||
expecting.store(ThreadEnd, std::memory_order_relaxed);
|
|
||||||
waitCondition.notify_all();
|
|
||||||
}
|
|
||||||
wait();
|
wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
void beginTest()
|
void beginTest()
|
||||||
{
|
{
|
||||||
const auto locker = qt_scoped_lock(mutex);
|
setExpectation(TestFunctionEnd);
|
||||||
expecting.store(TestFunctionEnd, std::memory_order_relaxed);
|
|
||||||
waitCondition.notify_all();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void testFinished()
|
void testFinished()
|
||||||
{
|
{
|
||||||
const auto locker = qt_scoped_lock(mutex);
|
setExpectation(TestFunctionStart);
|
||||||
expecting.store(TestFunctionStart, std::memory_order_relaxed);
|
|
||||||
waitCondition.notify_all();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void run() override
|
void run() override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user