ProjectExplorer: prepare for parallelization of recursive file scan

Change-Id: Ia2db3ef0fe619907c1ed30b8f984de4de04cc477
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
David Schulz
2024-06-05 10:50:43 +02:00
parent 5b93e34c00
commit f3e164af4f
7 changed files with 42 additions and 17 deletions

View File

@@ -83,12 +83,17 @@ CMakeBuildSystem::CMakeBuildSystem(CMakeBuildConfiguration *bc)
// Cache mime check result for speed up
if (!isIgnored) {
auto it = m_mimeBinaryCache.find(mimeType.name());
if (it != m_mimeBinaryCache.end()) {
if (auto it = m_mimeBinaryCache.get<std::optional<bool>>(
[mimeType](const QHash<QString, bool> &cache) -> std::optional<bool> {
auto it = cache.find(mimeType.name());
if (it != cache.end())
return *it;
return {};
})) {
isIgnored = *it;
} else {
isIgnored = TreeScanner::isMimeBinary(mimeType, fn);
m_mimeBinaryCache[mimeType.name()] = isIgnored;
m_mimeBinaryCache.writeLocked()->insert(mimeType.name(), isIgnored);
}
}

View File

@@ -10,6 +10,7 @@
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/buildsystem.h>
#include <utils/synchronizedvalue.h>
#include <utils/temporarydirectory.h>
namespace ProjectExplorer {
@@ -221,7 +222,7 @@ private:
ProjectExplorer::TreeScanner m_treeScanner;
std::shared_ptr<ProjectExplorer::FolderNode> m_allFiles;
QHash<QString, bool> m_mimeBinaryCache;
Utils::SynchronizedValue<QHash<QString, bool>> m_mimeBinaryCache;
bool m_waitingForParse = false;
bool m_combinedScanAndParseResult = false;