From e2e1a081408c23ea0c67a725cd57f1820e51b2a2 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 17 Aug 2012 10:53:53 +0200 Subject: [PATCH] QThreadPool: don't loop unless needed The resulting code is easier to understand, too. Change-Id: I3cd84d85b3186860dd3ccd67c3771b82695e7f83 Reviewed-by: Olivier Goffart --- src/corelib/thread/qthreadpool.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/thread/qthreadpool.cpp b/src/corelib/thread/qthreadpool.cpp index abbb683b833..4c705f5a93e 100644 --- a/src/corelib/thread/qthreadpool.cpp +++ b/src/corelib/thread/qthreadpool.cpp @@ -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 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();