summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThomas Sondergaard <ts@medical-insight.com>2010-05-26 08:52:19 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2010-05-26 08:52:41 (GMT)
commit497cd2c5dfda11fff9233fc951813d6b84c78eed (patch)
treef3b4ce78abbdb90c444f87111e6caa8f09153cfb /tests
parent0218fb14f3f05df746d7730f45a6137b33029dad (diff)
downloadQt-497cd2c5dfda11fff9233fc951813d6b84c78eed.zip
Qt-497cd2c5dfda11fff9233fc951813d6b84c78eed.tar.gz
Qt-497cd2c5dfda11fff9233fc951813d6b84c78eed.tar.bz2
Added QThreadPool::waitForDone(int msecs)
Merge-request: 641 Reviewed-by: Olivier Goffart <olivier.goffart@nokia.com> Reviewed-by: Morten Sorvig Task-number: QTBUG-2695
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qthreadpool/tst_qthreadpool.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/auto/qthreadpool/tst_qthreadpool.cpp b/tests/auto/qthreadpool/tst_qthreadpool.cpp
index 7c8b410..cd6070f 100644
--- a/tests/auto/qthreadpool/tst_qthreadpool.cpp
+++ b/tests/auto/qthreadpool/tst_qthreadpool.cpp
@@ -89,6 +89,7 @@ private slots:
void tryStartPeakThreadCount();
void tryStartCount();
void waitForDone();
+ void waitForDoneTimeout();
void destroyingWaitsForTasksToFinish();
void stressTest();
};
@@ -774,6 +775,32 @@ void tst_QThreadPool::waitForDone()
}
}
+void tst_QThreadPool::waitForDoneTimeout()
+{
+ class BlockedTask : public QRunnable
+ {
+ public:
+ QMutex mutex;
+ BlockedTask() { setAutoDelete(false); }
+
+ void run()
+ {
+ mutex.lock();
+ mutex.unlock();
+ QTest::qSleep(50);
+ }
+ };
+
+ QThreadPool threadPool;
+
+ BlockedTask *task = new BlockedTask;
+ task->mutex.lock();
+ threadPool.start(task);
+ QVERIFY(!threadPool.waitForDone(100));
+ task->mutex.unlock();
+ QVERIFY(threadPool.waitForDone(400));
+}
+
void tst_QThreadPool::destroyingWaitsForTasksToFinish()
{
QTime total, pass;