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:
Marc Mutz 2012-08-17 10:53:53 +02:00 committed by Qt by Nokia
parent 6ac6bc03e8
commit e2e1a08140

View File

@ -268,7 +268,7 @@ void QThreadPoolPrivate::reset()
isExiting = true;
runnableReady.wakeAll();
do {
while (!allThreads.empty()) {
// make a copy of the set so that we can iterate without the lock
QSet<QThreadPoolThread *> allThreadsCopy = allThreads;
allThreads.clear();
@ -281,7 +281,7 @@ void QThreadPoolPrivate::reset()
locker.relock();
// repeat until all newly arrived threads have also completed
} while (!allThreads.isEmpty());
}
waitingThreads = 0;
expiredThreads.clear();