diff options
author | Vitaly Fanaskov <vitaly.fanaskov@qt.io> | 2020-03-31 11:22:02 +0200 |
---|---|---|
committer | Vitaly Fanaskov <vitaly.fanaskov@qt.io> | 2020-04-14 17:44:13 +0200 |
commit | 678b9f78a5af4513ed4e988de90148584a2ae90d (patch) | |
tree | 090b7970c739396d20a758bd87280b13ee9159cf /tests/auto | |
parent | c028cbccc248581ca37389fa50e02a988d006348 (diff) |
QTaskBuilder::spawn: add an overload that doesn't return a future object
Fixes: QTBUG-83175
Change-Id: Idf85e47a2732742884272200d5c753805eaa640b
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/concurrent/qtconcurrenttask/tst_qtconcurrenttask.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/auto/concurrent/qtconcurrenttask/tst_qtconcurrenttask.cpp b/tests/auto/concurrent/qtconcurrenttask/tst_qtconcurrenttask.cpp index 0d08efa463..b8a82dfa14 100644 --- a/tests/auto/concurrent/qtconcurrenttask/tst_qtconcurrenttask.cpp +++ b/tests/auto/concurrent/qtconcurrenttask/tst_qtconcurrenttask.cpp @@ -43,6 +43,7 @@ private Q_SLOTS: void useCustomThreadPool(); void setPriority(); void adjustAllSettings(); + void ignoreFutureResult(); }; using namespace QtConcurrent; @@ -155,6 +156,20 @@ void tst_QtConcurrentTask::adjustAllSettings() QCOMPARE(result, QVector<int>({1, 2, 3})); } +void tst_QtConcurrentTask::ignoreFutureResult() +{ + QThreadPool pool; + + std::atomic_int value = 0; + for (std::size_t i = 0; i < 10; ++i) + task([&value]{ ++value; }) + .onThreadPool(pool) + .spawn(FutureResult::Ignore); + + pool.waitForDone(); + + QCOMPARE(value, 10); +} QTEST_MAIN(tst_QtConcurrentTask) #include "tst_qtconcurrenttask.moc" |