summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/thread
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2021-01-28 12:36:59 +0000
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2021-01-29 10:55:42 +0000
commitf2c3b52c6c513ebba9dc0db69efe8bdbf6be8334 (patch)
treeba924e5dfb28339e517dc1868bfe5ecf228d261d /tests/auto/corelib/thread
parentbd520ccc3c5742e7af61fef66bab96575b7b67ac (diff)
Revert "Port QThreadPool to the new property system"
This reverts commit 8f8405e04642b98663d4752d4ae76c304ae33b01. Reason for revert: Appears not entirely thread-safe and caused QTBUG-90705 Change-Id: I390c0b1a555a18e6a095b52010371d017071e26b Fixes: QTBUG-90705 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Diffstat (limited to 'tests/auto/corelib/thread')
-rw-r--r--tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp92
1 files changed, 14 insertions, 78 deletions
diff --git a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp
index 00c8a84ca7..5960ac20a3 100644
--- a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp
+++ b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp
@@ -104,23 +104,8 @@ private slots:
void stressTest();
void takeAllAndIncreaseMaxThreadCount();
void waitForDoneAfterTake();
- void bindings();
private:
- class WaitingTask : public QRunnable
- {
- public:
- QSemaphore waitForStarted, waitToFinish;
-
- WaitingTask() { setAutoDelete(false); }
-
- void run() override
- {
- waitForStarted.release();
- waitToFinish.acquire();
- }
- };
-
QMutex m_functionTestMutex;
};
@@ -486,6 +471,20 @@ void tst_QThreadPool::setMaxThreadCount()
void tst_QThreadPool::setMaxThreadCountStartsAndStopsThreads()
{
+ class WaitingTask : public QRunnable
+ {
+ public:
+ QSemaphore waitForStarted, waitToFinish;
+
+ WaitingTask() { setAutoDelete(false); }
+
+ void run() override
+ {
+ waitForStarted.release();
+ waitToFinish.acquire();
+ }
+ };
+
QThreadPool threadPool;
threadPool.setMaxThreadCount(1);
@@ -1306,68 +1305,5 @@ void tst_QThreadPool::waitForDoneAfterTake()
}
-void tst_QThreadPool::bindings()
-{
- {
- QThreadPool pool;
-
- // expiryTimeout property
- QProperty<int> expiryTimeout;
- pool.bindableExpiryTimeout().setBinding(Qt::makePropertyBinding(expiryTimeout));
- expiryTimeout = 1000;
- QCOMPARE(pool.expiryTimeout(), 1000);
-
- QProperty<int> expiryTimeoutObserver;
- expiryTimeoutObserver.setBinding(pool.bindableExpiryTimeout().makeBinding());
- pool.setExpiryTimeout(100);
- QCOMPARE(expiryTimeoutObserver, 100);
-
- // stackSize property
- QProperty<uint> stackSize;
- pool.bindableStackSize().setBinding(Qt::makePropertyBinding(stackSize));
- stackSize = 1000;
- QCOMPARE(pool.stackSize(), 1000);
-
- QProperty<uint> stackSizeObserver;
- stackSizeObserver.setBinding(pool.bindableStackSize().makeBinding());
- pool.setStackSize(100);
- QCOMPARE(stackSizeObserver, 100);
- }
-
- // maxThreadCount property
- {
- // Make sure changing the max thread count via binding starts new threads
- QThreadPool pool;
- WaitingTask task;
-
- pool.setMaxThreadCount(1);
- pool.start(&task);
- pool.start(&task);
- QVERIFY(task.waitForStarted.tryAcquire(1, 1000));
-
- // thread limit is 1, cannot start more tasks
- QVERIFY(!task.waitForStarted.tryAcquire(1, 1000));
- QCOMPARE(pool.activeThreadCount(), 1);
-
- QProperty<int> maxThreadCount;
- pool.bindableMaxThreadCount().setBinding(Qt::makePropertyBinding(maxThreadCount));
-
- maxThreadCount = 2;
- QCOMPARE(pool.maxThreadCount(), 2);
-
- // increasing thread count should allow starting more tasks
- QVERIFY(task.waitForStarted.tryAcquire(1, 1000));
- QCOMPARE(pool.activeThreadCount(), 2);
-
- task.waitToFinish.release(2);
- pool.waitForDone();
-
- QProperty<int> maxThreadCountObserver;
- maxThreadCountObserver.setBinding(pool.bindableMaxThreadCount().makeBinding());
- pool.setMaxThreadCount(10);
- QCOMPARE(maxThreadCountObserver, 10);
- }
-}
-
QTEST_MAIN(tst_QThreadPool);
#include "tst_qthreadpool.moc"