diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-09-25 15:40:48 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2018-11-12 13:00:56 +0000 |
commit | 75818581488c88454cf69e6326f5172734592729 (patch) | |
tree | cb0f14fceaadb7d327a475eff44db27cfa0f4ee1 /src/corelib/thread/qthreadpool_p.h | |
parent | a6a5e81cd6a627108382270c482df8a5e7939f7d (diff) |
Make QThreadPool::waitForDone more atomic
Avoid having the reset in waitForDone interfere with other uses of the
thread-pool by locking the mutex higher, and maintaining the state
so the queues doesn't have threads not in allThreads.
Task-number: QTBUG-62865
Change-Id: I17ee95d5f0e138ec15e785c6d61bb0fe064d3659
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/corelib/thread/qthreadpool_p.h')
-rw-r--r-- | src/corelib/thread/qthreadpool_p.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/corelib/thread/qthreadpool_p.h b/src/corelib/thread/qthreadpool_p.h index 0e6a00d243..952e02ef20 100644 --- a/src/corelib/thread/qthreadpool_p.h +++ b/src/corelib/thread/qthreadpool_p.h @@ -63,6 +63,8 @@ QT_REQUIRE_CONFIG(thread); QT_BEGIN_NAMESPACE +class QDeadlineTimer; + class QueuePage { public: enum { @@ -163,12 +165,13 @@ public: void startThread(QRunnable *runnable = 0); void reset(); bool waitForDone(int msecs); + bool waitForDone(const QDeadlineTimer &timer); void clear(); void stealAndRunRunnable(QRunnable *runnable); void deletePageIfFinished(QueuePage *page); mutable QMutex mutex; - QList<QThreadPoolThread *> allThreads; + QSet<QThreadPoolThread *> allThreads; QQueue<QThreadPoolThread *> waitingThreads; QQueue<QThreadPoolThread *> expiredThreads; QVector<QueuePage*> queue; @@ -179,7 +182,6 @@ public: int reservedThreads = 0; int activeThreads = 0; uint stackSize = 0; - bool isExiting = false; }; QT_END_NAMESPACE |