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 <tobias.hunger@theqtcompany.com>
This commit is contained in:
Eike Ziller
2016-01-27 14:33:44 +01:00
parent 349b49caaa
commit 2a83564d62
3 changed files with 13 additions and 1 deletions

View File

@@ -139,6 +139,7 @@
#include <QFileDialog>
#include <QMenu>
#include <QMessageBox>
#include <QThreadPool>
#include <QTimer>
/*!
@@ -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

View File

@@ -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();

View File

@@ -1800,7 +1800,9 @@ void QmakeProFileNode::asyncUpdate()
m_readerExact->setExact(false);
m_parseFutureWatcher.waitForFinished();
EvalInput input = evalInput();
QFuture<EvalResult *> future = QtConcurrent::run(&QmakeProFileNode::asyncEvaluate, this, input);
QFuture<EvalResult *> future = Utils::runAsync<EvalResult *>(ProjectExplorerPlugin::sharedThreadPool(),
&QmakeProFileNode::asyncEvaluate,
this, input);
m_parseFutureWatcher.setFuture(future);
}