Commit 6234511a authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

CppTools: Use a shared thread pool

Without this, too many threads are spawned, and loading a project takes
forever.

Change-Id: I3c22557ddd7bfb0c70f7b089c276432e3b003097
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent 9c0faff7
......@@ -204,9 +204,11 @@ BuiltinEditorDocumentProcessor::~BuiltinEditorDocumentProcessor()
void BuiltinEditorDocumentProcessor::run()
{
m_parserFuture = Utils::runAsync(runParser,
CppModelManager *mgr = CppModelManager::instance();
m_parserFuture = Utils::runAsync(mgr->sharedThreadPool(),
runParser,
parser(),
CppModelManager::instance()->workingCopy());
mgr->workingCopy());
}
BaseEditorDocumentParser::Ptr BuiltinEditorDocumentProcessor::parser()
......
......@@ -353,7 +353,7 @@ QFuture<void> BuiltinIndexingSupport::refreshSourceFiles(const QSet<QString> &so
params.workingCopy = mgr->workingCopy();
params.sourceFiles = sourceFiles;
QFuture<void> result = Utils::runAsync(parse, params);
QFuture<void> result = Utils::runAsync(mgr->sharedThreadPool(), parse, params);
if (m_synchronizer.futures().size() > 10) {
QList<QFuture<void> > futures = m_synchronizer.futures();
......
......@@ -365,7 +365,8 @@ void CppFindReferences::findAll_helper(SearchResult *search, Symbol *symbol,
SearchResultWindow::instance()->popup(IOutputPane::ModeSwitch | IOutputPane::WithFocus);
const WorkingCopy workingCopy = m_modelManager->workingCopy();
QFuture<Usage> result;
result = Utils::runAsync(find_helper, workingCopy, context, symbol);
result = Utils::runAsync(m_modelManager->sharedThreadPool(), find_helper,
workingCopy, context, symbol);
createWatcher(result, search);
FutureProgress *progress = ProgressManager::addTask(result, tr("Searching for Usages"),
......@@ -669,7 +670,8 @@ void CppFindReferences::findMacroUses(const Macro &macro, const QString &replace
}
QFuture<Usage> result;
result = Utils::runAsync(findMacroUses_helper, workingCopy, snapshot, macro);
result = Utils::runAsync(m_modelManager->sharedThreadPool(), findMacroUses_helper,
workingCopy, snapshot, macro);
createWatcher(result, search);
FutureProgress *progress = ProgressManager::addTask(result, tr("Searching for Usages"),
......
......@@ -58,6 +58,7 @@
#include <QDir>
#include <QMutexLocker>
#include <QTextBlock>
#include <QThreadPool>
#include <QTimer>
#if defined(QTCREATOR_WITH_DUMP_AST) && defined(Q_CC_GNU)
......@@ -157,6 +158,7 @@ public:
CppFindReferences *m_findReferences;
SymbolFinder m_symbolFinder;
QThreadPool m_threadPool;
bool m_enableGC;
QTimer m_delayedGcTimer;
......@@ -1196,4 +1198,9 @@ SymbolFinder *CppModelManager::symbolFinder()
return &d->m_symbolFinder;
}
QThreadPool *CppModelManager::sharedThreadPool()
{
return &d->m_threadPool;
}
} // namespace CppTools
......@@ -162,6 +162,8 @@ public:
SymbolFinder *symbolFinder();
QThreadPool *sharedThreadPool();
static QSet<QString> timeStampModifiedFiles(const QList<Document::Ptr> &documentsToCheck);
static Internal::CppSourceProcessor *createSourceProcessor();
......
......@@ -26,6 +26,7 @@
#include "cppsemanticinfoupdater.h"
#include "cpplocalsymbols.h"
#include "cppmodelmanager.h"
#include <utils/qtcassert.h>
#include <utils/runextensions.h>
......@@ -200,7 +201,8 @@ void SemanticInfoUpdater::updateDetached(const SemanticInfo::Source source)
return;
}
d->m_future = Utils::runAsync(&SemanticInfoUpdaterPrivate::update_helper, d.data(), source);
d->m_future = Utils::runAsync(CppModelManager::instance()->sharedThreadPool(),
&SemanticInfoUpdaterPrivate::update_helper, d.data(), source);
}
SemanticInfo SemanticInfoUpdater::semanticInfo() const
......
......@@ -145,7 +145,8 @@ void SymbolsFindFilter::startSearch(SearchResult *search)
SymbolSearcher *symbolSearcher = m_manager->indexingSupport()->createSymbolSearcher(parameters, projectFileNames);
connect(watcher, SIGNAL(finished()),
symbolSearcher, SLOT(deleteLater()));
watcher->setFuture(Utils::runAsync(&SymbolSearcher::runSearch, symbolSearcher));
watcher->setFuture(Utils::runAsync(m_manager->sharedThreadPool(),
&SymbolSearcher::runSearch, symbolSearcher));
FutureProgress *progress = ProgressManager::addTask(watcher->future(), tr("Searching for Symbol"),
Core::Constants::TASK_SEARCH);
connect(progress, SIGNAL(clicked()), search, SLOT(popup()));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment