QThreadPool: don't loop unless needed
The resulting code is easier to understand, too. Change-Id: I3cd84d85b3186860dd3ccd67c3771b82695e7f83 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
This commit is contained in:
parent
6ac6bc03e8
commit
e2e1a08140
@ -268,7 +268,7 @@ void QThreadPoolPrivate::reset()
|
|||||||
isExiting = true;
|
isExiting = true;
|
||||||
runnableReady.wakeAll();
|
runnableReady.wakeAll();
|
||||||
|
|
||||||
do {
|
while (!allThreads.empty()) {
|
||||||
// make a copy of the set so that we can iterate without the lock
|
// make a copy of the set so that we can iterate without the lock
|
||||||
QSet<QThreadPoolThread *> allThreadsCopy = allThreads;
|
QSet<QThreadPoolThread *> allThreadsCopy = allThreads;
|
||||||
allThreads.clear();
|
allThreads.clear();
|
||||||
@ -281,7 +281,7 @@ void QThreadPoolPrivate::reset()
|
|||||||
|
|
||||||
locker.relock();
|
locker.relock();
|
||||||
// repeat until all newly arrived threads have also completed
|
// repeat until all newly arrived threads have also completed
|
||||||
} while (!allThreads.isEmpty());
|
}
|
||||||
|
|
||||||
waitingThreads = 0;
|
waitingThreads = 0;
|
||||||
expiredThreads.clear();
|
expiredThreads.clear();
|
||||||
|
Loading…
Reference in New Issue
Block a user