diff --git a/src/plugins/cpptools/builtineditordocumentprocessor.cpp b/src/plugins/cpptools/builtineditordocumentprocessor.cpp index b3a184139db..a7a7ac1a338 100644 --- a/src/plugins/cpptools/builtineditordocumentprocessor.cpp +++ b/src/plugins/cpptools/builtineditordocumentprocessor.cpp @@ -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() diff --git a/src/plugins/cpptools/builtinindexingsupport.cpp b/src/plugins/cpptools/builtinindexingsupport.cpp index 81a5be27df8..b2fc32159d9 100644 --- a/src/plugins/cpptools/builtinindexingsupport.cpp +++ b/src/plugins/cpptools/builtinindexingsupport.cpp @@ -353,7 +353,7 @@ QFuture BuiltinIndexingSupport::refreshSourceFiles(const QSet &so params.workingCopy = mgr->workingCopy(); params.sourceFiles = sourceFiles; - QFuture result = Utils::runAsync(parse, params); + QFuture result = Utils::runAsync(mgr->sharedThreadPool(), parse, params); if (m_synchronizer.futures().size() > 10) { QList > futures = m_synchronizer.futures(); diff --git a/src/plugins/cpptools/cppfindreferences.cpp b/src/plugins/cpptools/cppfindreferences.cpp index d8732be1f9c..0f7bc7e2c46 100644 --- a/src/plugins/cpptools/cppfindreferences.cpp +++ b/src/plugins/cpptools/cppfindreferences.cpp @@ -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 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 ¯o, const QString &replace } QFuture 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"), diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp index e8490f90953..4517bd8e9f5 100644 --- a/src/plugins/cpptools/cppmodelmanager.cpp +++ b/src/plugins/cpptools/cppmodelmanager.cpp @@ -58,6 +58,7 @@ #include #include #include +#include #include #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 diff --git a/src/plugins/cpptools/cppmodelmanager.h b/src/plugins/cpptools/cppmodelmanager.h index 8d0013a83d7..27486045f68 100644 --- a/src/plugins/cpptools/cppmodelmanager.h +++ b/src/plugins/cpptools/cppmodelmanager.h @@ -162,6 +162,8 @@ public: SymbolFinder *symbolFinder(); + QThreadPool *sharedThreadPool(); + static QSet timeStampModifiedFiles(const QList &documentsToCheck); static Internal::CppSourceProcessor *createSourceProcessor(); diff --git a/src/plugins/cpptools/cppsemanticinfoupdater.cpp b/src/plugins/cpptools/cppsemanticinfoupdater.cpp index a95c90521ce..6df0c69b157 100644 --- a/src/plugins/cpptools/cppsemanticinfoupdater.cpp +++ b/src/plugins/cpptools/cppsemanticinfoupdater.cpp @@ -26,6 +26,7 @@ #include "cppsemanticinfoupdater.h" #include "cpplocalsymbols.h" +#include "cppmodelmanager.h" #include #include @@ -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 diff --git a/src/plugins/cpptools/symbolsfindfilter.cpp b/src/plugins/cpptools/symbolsfindfilter.cpp index 6d88b9deaf7..5e98af1c549 100644 --- a/src/plugins/cpptools/symbolsfindfilter.cpp +++ b/src/plugins/cpptools/symbolsfindfilter.cpp @@ -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()));