summaryrefslogtreecommitdiffstats
path: root/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp')
-rw-r--r--tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp b/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp
index 1b0ac7a8bc..bd53aa69fe 100644
--- a/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp
+++ b/tests/auto/concurrent/qtconcurrentrun/tst_qtconcurrentrun.cpp
@@ -464,6 +464,19 @@ int throwFunctionReturn()
return 0;
}
+class SlowTask : public QRunnable
+{
+public:
+ static QAtomicInt cancel;
+ void run() Q_DECL_OVERRIDE {
+ int iter = 60;
+ while (--iter && !cancel.load())
+ QThread::currentThread()->msleep(25);
+ }
+};
+
+QAtomicInt SlowTask::cancel;
+
void tst_QtConcurrentRun::exceptions()
{
QThreadPool pool;
@@ -504,6 +517,30 @@ void tst_QtConcurrentRun::exceptions()
}
if (!caught)
QFAIL("did not get exception");
+
+ caught = false;
+ try {
+ QtConcurrent::run(&pool, throwFunctionReturn).result();
+ } catch (QException &) {
+ caught = true;
+ }
+ QVERIFY2(caught, "did not get exception");
+
+ // Force the task to be run on this thread.
+ caught = false;
+ QThreadPool shortPool;
+ shortPool.setMaxThreadCount(1);
+ SlowTask *st = new SlowTask();
+ try {
+ shortPool.start(st);
+ QtConcurrent::run(&shortPool, throwFunctionReturn).result();
+ } catch (QException &) {
+ caught = true;
+ }
+
+ SlowTask::cancel.store(true);
+
+ QVERIFY2(caught, "did not get exception");
}
#endif