diff options
author | Tim Jenssen <tim.jenssen@qt.io> | 2022-08-23 16:27:14 +0200 |
---|---|---|
committer | Tim Jenssen <tim.jenssen@qt.io> | 2022-08-23 17:20:14 +0000 |
commit | 8310a2f0a9a4d15af589da948928181630d8f4bd (patch) | |
tree | 15acae84bb3197770656a8b4f7400a53558924c9 | |
parent | 275f2a3db8bbbde177512eeb3e06cd36217df8f1 (diff) | |
download | qt-creator-8310a2f0a9a4d15af589da948928181630d8f4bd.tar.gz |
qmljs: reduce used threads
Change-Id: I8f27037d0cfefd65f1ac060e1505328ea705a670
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
-rw-r--r-- | src/libs/qmljs/qmljsmodelmanagerinterface.cpp | 22 | ||||
-rw-r--r-- | src/libs/qmljs/qmljsmodelmanagerinterface.h | 2 | ||||
-rw-r--r-- | src/libs/qmljs/qmljsplugindumper.cpp | 5 |
3 files changed, 22 insertions, 7 deletions
diff --git a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp index 444d429a4b..af0b975542 100644 --- a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp +++ b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp @@ -111,6 +111,7 @@ ModelManagerInterface::ModelManagerInterface(QObject *parent) m_defaultImportPaths(environmentImportPaths()), m_pluginDumper(new PluginDumper(this)) { + m_threadPool.setMaxThreadCount(4); m_futureSynchronizer.setCancelOnWait(false); m_indexerDisabled = qEnvironmentVariableIsSet("QTC_NO_CODE_INDEXER"); @@ -326,6 +327,11 @@ Snapshot ModelManagerInterface::newestSnapshot() const return m_newestSnapshot; } +QThreadPool *ModelManagerInterface::threadPool() +{ + return &m_threadPool; +} + void ModelManagerInterface::updateSourceFiles(const QStringList &files, bool emitDocumentOnDiskChanged) { @@ -340,7 +346,8 @@ QFuture<void> ModelManagerInterface::refreshSourceFiles(const QStringList &sourc if (sourceFiles.isEmpty()) return QFuture<void>(); - QFuture<void> result = Utils::runAsync(&ModelManagerInterface::parse, + QFuture<void> result = Utils::runAsync(&m_threadPool, + &ModelManagerInterface::parse, workingCopyInternal(), sourceFiles, this, Dialect(Dialect::Qml), emitDocumentOnDiskChanged); @@ -368,9 +375,13 @@ QFuture<void> ModelManagerInterface::refreshSourceFiles(const QStringList &sourc void ModelManagerInterface::fileChangedOnDisk(const QString &path) { - addFuture(Utils::runAsync(&ModelManagerInterface::parse, - workingCopyInternal(), QStringList(path), - this, Dialect(Dialect::AnyLanguage), true)); + addFuture(Utils::runAsync(&m_threadPool, + &ModelManagerInterface::parse, + workingCopyInternal(), + QStringList(path), + this, + Dialect(Dialect::AnyLanguage), + true)); } void ModelManagerInterface::removeFiles(const QStringList &files) @@ -1191,7 +1202,8 @@ void ModelManagerInterface::maybeScan(const PathsAndLanguages &importPaths) } if (pathToScan.length() >= 1) { - QFuture<void> result = Utils::runAsync(&ModelManagerInterface::importScan, + QFuture<void> result = Utils::runAsync(&m_threadPool, + &ModelManagerInterface::importScan, workingCopyInternal(), pathToScan, this, true, true, false); addFuture(result); diff --git a/src/libs/qmljs/qmljsmodelmanagerinterface.h b/src/libs/qmljs/qmljsmodelmanagerinterface.h index 4ed02c2c96..b0b28e8d1a 100644 --- a/src/libs/qmljs/qmljsmodelmanagerinterface.h +++ b/src/libs/qmljs/qmljsmodelmanagerinterface.h @@ -133,6 +133,7 @@ public: QmlJS::Snapshot snapshot() const; QmlJS::Snapshot newestSnapshot() const; + QThreadPool *threadPool(); void activateScan(); void updateSourceFiles(const QStringList &files, @@ -287,6 +288,7 @@ private: Utils::FutureSynchronizer m_futureSynchronizer; bool m_indexerDisabled = false; + QThreadPool m_threadPool; }; } // namespace QmlJS diff --git a/src/libs/qmljs/qmljsplugindumper.cpp b/src/libs/qmljs/qmljsplugindumper.cpp index 56d444f9d9..0a13fefba9 100644 --- a/src/libs/qmljs/qmljsplugindumper.cpp +++ b/src/libs/qmljs/qmljsplugindumper.cpp @@ -290,7 +290,8 @@ void PluginDumper::qmlPluginTypeDumpDone(QtcProcess *process) QStringList dependencies; }; - auto future = Utils::runAsync([output, libraryPath](QFutureInterface<CppQmlTypesInfo>& future) + auto future = Utils::runAsync(m_modelManager->threadPool(), + [output, libraryPath](QFutureInterface<CppQmlTypesInfo>& future) { CppQmlTypesInfo infos; CppQmlTypesLoader::parseQmlTypeDescriptions(output, &infos.objectsList, &infos.moduleApis, &infos.dependencies, @@ -343,7 +344,7 @@ void PluginDumper::pluginChanged(const QString &pluginLibrary) QFuture<PluginDumper::QmlTypeDescription> PluginDumper::loadQmlTypeDescription(const FilePaths &paths) const { - auto future = Utils::runAsync([=](QFutureInterface<PluginDumper::QmlTypeDescription> &future) + auto future = Utils::runAsync(m_modelManager->threadPool(), [=](QFutureInterface<PluginDumper::QmlTypeDescription> &future) { PluginDumper::QmlTypeDescription result; |