Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
4.8.7, 5.12.0, 6.2.0 Beta4
-
None
-
linux 2.6, gcc 4.8.4, qt 4.8.7
windows 7, mingw7.3 64bit, qt 5.12.0
-
-
21
-
1afd562b0b0bbba02575aa79601f0fae555cfa19 7cd69f9af057f4b48b259004b032f241b72f0de9 (qt/qtbase/6.2) 14b0d9a50f1679daabb0f5a64368006f7a64a189 (qt/tqtc-qtbase/5.15)
-
Team 1 Foundation_Sprint 42
Description
In some case, I want to use nested QtConcurrent::map(another map in a mapped task), such as following example, but the code can not run forever, it will hang quickly:
// code placeholder #include <cassert> #include <QtConcurrentMap> #include <QtConcurrentRun> #include <QFuture> #include <QThreadPool> #include <QtTest/QTest> #include <QFutureSynchronizer> struct Task2 { // only calculation typedef void result_type; void operator()(int count) { int k = 0; k += count; assert(k >= 0); } }; struct Task1 { // will launch some other concurrent map typedef void result_type; void operator()(int count) { QVector<int> vec; vec.push_back(count); // only one element Task2 task; QFuture<void> f = QtConcurrent::map(vec.begin(), vec.end(), task); { // with out releaseThread before wait, it will hang directly QThreadPool::globalInstance()->releaseThread(); f.waitForFinished(); // BUG: may hang there QThreadPool::globalInstance()->reserveThread(); } } }; int main() { int count = 0; for (;;) { QVector<int> vec; vec.push_back(0); // only one element // launch a task with nested map Task1 task; // Task1 will have nested concurrent map QFuture<void> f = QtConcurrent::map(vec.begin(), vec.end(),task); f.waitForFinished(); // BUG: may hang there count++; qDebug() << count; } return 0; }
Attachments
For Gerrit Dashboard: QTBUG-72872 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
370945,4 | QThreadPool: Fix restarting of expired threads | dev | qt/qtbase | Status: MERGED | +2 | 0 |
370946,2 | tst_qthreadpool: Add new regression test threadReuse() | dev | qt/qtbase | Status: ABANDONED | 0 | 0 |
371114,2 | QThreadPool: Fix restarting of expired threads | 6.2 | qt/qtbase | Status: MERGED | +2 | 0 |
371123,2 | QThreadPool: Fix restarting of expired threads | 6.2.0 | qt/qtbase | Status: ABANDONED | +2 | 0 |
371168,2 | QThreadPool: Fix restarting of expired threads | tqtc/lts-5.15 | qt/tqtc-qtbase | Status: MERGED | +2 | 0 |