Use new QSemaphoreReleaser in tst_QThreadPool
... replacing a hand-rolled version there. Change-Id: I0db50acd1ecf591d608eb719021a6fcd06aeb226 Reviewed-by: David Faure <david.faure@kdab.com>bb10
parent
07ec102195
commit
1567a7c0f4
|
|
@ -961,21 +961,6 @@ void tst_QThreadPool::cancel()
|
|||
QSemaphore sem(0);
|
||||
QSemaphore startedThreads(0);
|
||||
|
||||
class SemaphoreReleaser
|
||||
{
|
||||
QSemaphore &sem;
|
||||
int n;
|
||||
Q_DISABLE_COPY(SemaphoreReleaser)
|
||||
public:
|
||||
explicit SemaphoreReleaser(QSemaphore &sem, int n)
|
||||
: sem(sem), n(n) {}
|
||||
|
||||
~SemaphoreReleaser()
|
||||
{
|
||||
sem.release(n);
|
||||
}
|
||||
};
|
||||
|
||||
class BlockingRunnable : public QRunnable
|
||||
{
|
||||
public:
|
||||
|
|
@ -1014,7 +999,7 @@ void tst_QThreadPool::cancel()
|
|||
|
||||
// ensure that the QThreadPool doesn't deadlock if any of the checks fail
|
||||
// and cause an early return:
|
||||
const SemaphoreReleaser semReleaser(sem, runs);
|
||||
const QSemaphoreReleaser semReleaser(sem, runs);
|
||||
|
||||
count.store(0);
|
||||
QAtomicInt dtorCounter = 0;
|
||||
|
|
@ -1048,21 +1033,6 @@ void tst_QThreadPool::tryTake()
|
|||
QSemaphore sem(0);
|
||||
QSemaphore startedThreads(0);
|
||||
|
||||
class SemaphoreReleaser
|
||||
{
|
||||
QSemaphore &sem;
|
||||
int n;
|
||||
Q_DISABLE_COPY(SemaphoreReleaser)
|
||||
public:
|
||||
explicit SemaphoreReleaser(QSemaphore &sem, int n)
|
||||
: sem(sem), n(n) {}
|
||||
|
||||
~SemaphoreReleaser()
|
||||
{
|
||||
sem.release(n);
|
||||
}
|
||||
};
|
||||
|
||||
class BlockingRunnable : public QRunnable
|
||||
{
|
||||
public:
|
||||
|
|
@ -1101,7 +1071,7 @@ void tst_QThreadPool::tryTake()
|
|||
|
||||
// ensure that the QThreadPool doesn't deadlock if any of the checks fail
|
||||
// and cause an early return:
|
||||
const SemaphoreReleaser semReleaser(sem, Runs);
|
||||
const QSemaphoreReleaser semReleaser(sem, Runs);
|
||||
|
||||
count.store(0);
|
||||
QAtomicInt dtorCounter = 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue