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>
This commit is contained in:
parent
90484f3901
commit
5170c0416b
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user