summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2015-12-26 03:33:04 +0100
committerMarc Mutz <marc.mutz@kdab.com>2016-01-04 12:22:50 +0000
commit5170c0416bc598414d026f35774c617173ce6ece (patch)
tree7b255f7aeccce18256518bf19cd06aaf4d92f691 /src/corelib/io
parent90484f3901c5fe63a056001eebf9ea62cac0cf58 (diff)
QWindowsFileSystemWatcher: increase concurrency when canceling threads
The old code asked each thread to stop, and then waited for that one thread to finish before deleting it and turning to the next thread in line. Split the three actions, ie. first ask all threads to stop, then wait for all threads to finish, and only then delete all of them. Apart from being more icache-friendly, this enables more concurrency, as stopped threads' cleanup work can overlap with other's, thus reducing the wait() time per thread to potentially zero. Did not replicate the inefficient foreach loop, but went with C++11 range-fors directly. Change-Id: I53e598e31999a772c0f81ff5885490216e13d492 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qfilesystemwatcher_win.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/corelib/io/qfilesystemwatcher_win.cpp b/src/corelib/io/qfilesystemwatcher_win.cpp
index 410753868e..2e01e1a857 100644
--- a/src/corelib/io/qfilesystemwatcher_win.cpp
+++ b/src/corelib/io/qfilesystemwatcher_win.cpp
@@ -62,11 +62,11 @@ QWindowsFileSystemWatcherEngine::Handle::Handle()
QWindowsFileSystemWatcherEngine::~QWindowsFileSystemWatcherEngine()
{
- foreach(QWindowsFileSystemWatcherEngineThread *thread, threads) {
+ for (auto *thread : qAsConst(threads))
thread->stop();
+ for (auto *thread : qAsConst(threads))
thread->wait();
- delete thread;
- }
+ qDeleteAll(threads);
}
QStringList QWindowsFileSystemWatcherEngine::addPaths(const QStringList &paths,