tst_qthreadpool: fix flaky test I introduced in last commit
(dacf9961da
)
In order to see 2 active threads, we must check activeThreadCount() before
the runnable finishes.
Change-Id: I1a48b41e0c1fd81a65d915b9bd1e741ff267ed2b
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
This commit is contained in:
parent
4774ff8eb1
commit
5eb91476f1
@ -638,6 +638,7 @@ void tst_QThreadPool::reserveAndStart() // QTBUG-21051
|
||||
public:
|
||||
QAtomicInt count;
|
||||
QSemaphore waitForStarted;
|
||||
QSemaphore waitBeforeDone;
|
||||
|
||||
WaitingTask() { setAutoDelete(false); }
|
||||
|
||||
@ -645,6 +646,7 @@ void tst_QThreadPool::reserveAndStart() // QTBUG-21051
|
||||
{
|
||||
count.ref();
|
||||
waitForStarted.release();
|
||||
waitBeforeDone.acquire();
|
||||
}
|
||||
};
|
||||
|
||||
@ -663,6 +665,7 @@ void tst_QThreadPool::reserveAndStart() // QTBUG-21051
|
||||
threadpool->start(task);
|
||||
QCOMPARE(threadpool->activeThreadCount(), 2);
|
||||
task->waitForStarted.acquire();
|
||||
task->waitBeforeDone.release();
|
||||
QTRY_COMPARE(task->count.load(), 1);
|
||||
QTRY_COMPARE(threadpool->activeThreadCount(), 1);
|
||||
|
||||
@ -675,6 +678,7 @@ void tst_QThreadPool::reserveAndStart() // QTBUG-21051
|
||||
threadpool->start(task);
|
||||
QTRY_COMPARE(threadpool->activeThreadCount(), 2);
|
||||
task->waitForStarted.acquire();
|
||||
task->waitBeforeDone.release();
|
||||
QTRY_COMPARE(task->count.load(), 2);
|
||||
QTRY_COMPARE(threadpool->activeThreadCount(), 1);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user