From 2a83564d6242e2b8500aee4392143bafc3de6de7 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Wed, 27 Jan 2016 14:33:44 +0100 Subject: [PATCH] QMakeProjectManager: Avoid usage of global thread pool. Using a global thread pool does not really make sense, since we do not want to block any completely unrelated task. But the qmake project manager still wants to limit the number of simultaneous threads without managing that itself. A shared thread pool in project explorer sounds like a sensible middle ground. Change-Id: Ide6fd546a56e8f4896c387168513b608dfe7e3e8 Reviewed-by: Tobias Hunger --- src/plugins/projectexplorer/projectexplorer.cpp | 7 +++++++ src/plugins/projectexplorer/projectexplorer.h | 3 +++ src/plugins/qmakeprojectmanager/qmakenodes.cpp | 4 +++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 0ee14ab5ff5..93e1aab014d 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -139,6 +139,7 @@ #include #include #include +#include #include /*! @@ -368,6 +369,7 @@ public: #ifdef WITH_JOURNALD JournaldWatcher *m_journalWatcher; #endif + QThreadPool m_threadPool; }; ProjectExplorerPluginPrivate::ProjectExplorerPluginPrivate() : @@ -1852,6 +1854,11 @@ void ProjectExplorerPlugin::updateContextMenuActions() dd->updateContextMenuActions(); } +QThreadPool *ProjectExplorerPlugin::sharedThreadPool() +{ + return &(dd->m_threadPool); +} + /*! This function is connected to the ICore::coreOpened signal. If there was no session explicitly loaded, it creates an empty new diff --git a/src/plugins/projectexplorer/projectexplorer.h b/src/plugins/projectexplorer/projectexplorer.h index d9aef1e31e2..82aa38e98f1 100644 --- a/src/plugins/projectexplorer/projectexplorer.h +++ b/src/plugins/projectexplorer/projectexplorer.h @@ -37,6 +37,7 @@ QT_BEGIN_NAMESPACE class QPoint; class QAction; +class QThreadPool; QT_END_NAMESPACE namespace Core { @@ -154,6 +155,8 @@ public: static void updateContextMenuActions(); + static QThreadPool *sharedThreadPool(); + private: static bool coreAboutToClose(); diff --git a/src/plugins/qmakeprojectmanager/qmakenodes.cpp b/src/plugins/qmakeprojectmanager/qmakenodes.cpp index aa74485653a..2808a6dd602 100644 --- a/src/plugins/qmakeprojectmanager/qmakenodes.cpp +++ b/src/plugins/qmakeprojectmanager/qmakenodes.cpp @@ -1800,7 +1800,9 @@ void QmakeProFileNode::asyncUpdate() m_readerExact->setExact(false); m_parseFutureWatcher.waitForFinished(); EvalInput input = evalInput(); - QFuture future = QtConcurrent::run(&QmakeProFileNode::asyncEvaluate, this, input); + QFuture future = Utils::runAsync(ProjectExplorerPlugin::sharedThreadPool(), + &QmakeProFileNode::asyncEvaluate, + this, input); m_parseFutureWatcher.setFuture(future); }