From ed97c785bca7caccd0c6922514ff68c19c62aa83 Mon Sep 17 00:00:00 2001 From: Roberto Raggi <roberto.raggi@nokia.com> Date: Fri, 6 Mar 2009 11:51:45 +0100 Subject: [PATCH] Removed the blockingMap, but continue to parse the collected documents in parallel. --- src/plugins/cpptools/cppmodelmanager.cpp | 28 ++++++------------------ 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp index a08d66bebef..3d4c73346d6 100644 --- a/src/plugins/cpptools/cppmodelmanager.cpp +++ b/src/plugins/cpptools/cppmodelmanager.cpp @@ -33,7 +33,10 @@ #include "cpptoolsconstants.h" #include "cpptoolseditorsupport.h" +#include <functional> +#include <QtConcurrentRun> #include <qtconcurrent/runextensions.h> + #include <texteditor/itexteditor.h> #include <texteditor/basetexteditor.h> @@ -171,8 +174,6 @@ public: void resetEnvironment(); - void parseCollectedDocuments(); - const QSet<QString> &todo() const { return m_todo; } @@ -211,7 +212,6 @@ private: QSet<QString> m_included; Document::Ptr m_currentDoc; QSet<QString> m_todo; - QList<Document::Ptr> m_documents; }; } // namespace Internal @@ -241,7 +241,7 @@ void CppPreprocessor::setTodo(const QStringList &files) namespace { -class Process +class Process: public std::unary_function<Document::Ptr, void> { QPointer<CppModelManager> _modelManager; @@ -250,7 +250,7 @@ public: : _modelManager(modelManager) { } - void operator()(Document::Ptr doc) + void operator()(Document::Ptr doc) const { doc->parse(); doc->check(); @@ -267,22 +267,11 @@ void CppPreprocessor::run(const QString &fileName) { QString absoluteFilePath = fileName; sourceNeeded(absoluteFilePath, IncludeGlobal, /*line = */ 0); - - if (m_documents.size() >= 8) - parseCollectedDocuments(); } void CppPreprocessor::resetEnvironment() { env.reset(); } -void CppPreprocessor::parseCollectedDocuments() -{ - QThread::currentThread()->setPriority(QThread::IdlePriority); - QtConcurrent::blockingMap(m_documents, Process(m_modelManager)); - QThread::currentThread()->setPriority(QThread::NormalPriority); - m_documents.clear(); -} - bool CppPreprocessor::includeFile(const QString &absoluteFilePath, QByteArray *result) { if (absoluteFilePath.isEmpty() || m_included.contains(absoluteFilePath)) { @@ -514,12 +503,11 @@ void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type, doc->releaseSource(); snapshot.insert(doc->fileName(), doc); + m_todo.remove(fileName); - m_documents.append(doc); + QtConcurrent::run(Process(m_modelManager), doc); (void) switchDocument(previousDoc); - - m_todo.remove(fileName); } Document::Ptr CppPreprocessor::switchDocument(Document::Ptr doc) @@ -1041,8 +1029,6 @@ void CppModelManager::parse(QFutureInterface<void> &future, QThread::currentThread()->setPriority(QThread::NormalPriority); } - preproc->parseCollectedDocuments(); - future.setProgressValue(files.size()); delete preproc; -- GitLab