logic: Limit multi process indexing to projects with C/C++ source groups

This commit is contained in:
Eberhard Graether
2017-05-08 14:45:37 +02:00
parent ad1a48bce4
commit 14fa67b909
6 changed files with 28 additions and 20 deletions
+4 -4
View File
@@ -27,11 +27,13 @@ TaskBuildIndex::TaskBuildIndex(
unsigned int processCount,
std::shared_ptr<IndexerCommandList> indexerCommandList,
std::shared_ptr<StorageProvider> storageProvider,
std::shared_ptr<FileRegisterStateData> fileRegisterStateData
std::shared_ptr<FileRegisterStateData> fileRegisterStateData,
bool multiProcessIndexing
)
: m_indexerCommandList(indexerCommandList)
, m_storageProvider(storageProvider)
, m_fileRegisterStateData(fileRegisterStateData)
, m_multiProcessIndexing(multiProcessIndexing)
, m_interprocessIndexerCommandManager(Application::getUUID(), 0, true)
, m_interprocessIndexingStatusManager(Application::getUUID(), 0, true)
, m_processCount(processCount)
@@ -61,8 +63,6 @@ void TaskBuildIndex::doEnter(std::shared_ptr<Blackboard> blackboard)
logFilePath = dynamic_cast<FileLogger*>(logger)->getLogFilePath().str();
}
bool multiProcess = ApplicationSettings::getInstance()->getMultiProcessIndexingEnabled();
// start indexer processes
for (unsigned int i = 0; i < m_processCount; i++)
{
@@ -72,7 +72,7 @@ void TaskBuildIndex::doEnter(std::shared_ptr<Blackboard> blackboard)
std::make_shared<InterprocessIntermediateStorageManager>(Application::getUUID(), processId, true)
);
if (multiProcess)
if (m_multiProcessIndexing)
{
m_processThreads.push_back(new std::thread(&TaskBuildIndex::runIndexerProcess, this, processId, logFilePath));
}
+3 -1
View File
@@ -25,7 +25,8 @@ public:
unsigned int processCount,
std::shared_ptr<IndexerCommandList> indexerCommandList,
std::shared_ptr<StorageProvider> storageProvider,
std::shared_ptr<FileRegisterStateData> fileRegisterStateData
std::shared_ptr<FileRegisterStateData> fileRegisterStateData,
bool multiProcessIndexing
);
protected:
@@ -47,6 +48,7 @@ protected:
std::shared_ptr<IndexerCommandList> m_indexerCommandList;
std::shared_ptr<StorageProvider> m_storageProvider;
std::shared_ptr<FileRegisterStateData> m_fileRegisterStateData;
bool m_multiProcessIndexing;
InterprocessIndexerCommandManager m_interprocessIndexerCommandManager;
InterprocessIndexingStatusManager m_interprocessIndexingStatusManager;
+16 -13
View File
@@ -382,17 +382,6 @@ bool Project::requestIndex(bool forceRefresh, bool needsFullRefresh)
utility::append(filesToIndex, sourceGroup->getSourceFilePathsToIndex());
}
bool hasCXXSourceGroup = false;
for (std::shared_ptr<SourceGroup> sourceGroup: m_sourceGroups)
{
if (sourceGroup->getLanguage() == LANGUAGE_C || sourceGroup->getLanguage() == LANGUAGE_CPP)
{
hasCXXSourceGroup = true;
break;
}
}
bool fullRefresh = forceRefresh | needsFullRefresh;
bool preprocessorOnly = false;
@@ -402,7 +391,7 @@ bool Project::requestIndex(bool forceRefresh, bool needsFullRefresh)
options.fullRefreshVisible = !needsFullRefresh;
options.fullRefresh = forceRefresh;
options.preprocessorOnlyVisible = hasCXXSourceGroup;
options.preprocessorOnlyVisible = hasCxxSourceGroup();
options.preprocessorOnly = false;
Application::getInstance()->getDialogView()->hideUnknownProgressDialog();
@@ -502,9 +491,11 @@ void Project::buildIndex(const std::set<FilePath>& filesToClean, bool fullRefres
// add task for indexing
if (indexerThreadCount > 0)
{
bool multiProcess = ApplicationSettings::getInstance()->getMultiProcessIndexingEnabled() && hasCxxSourceGroup();
taskParallelIndexing->addChildTasks(
std::make_shared<TaskDecoratorRepeat>(TaskDecoratorRepeat::CONDITION_WHILE_SUCCESS, Task::STATE_SUCCESS)->addChildTask(
std::make_shared<TaskBuildIndex>(indexerThreadCount, indexerCommandList, storageProvider, fileRegisterStateData)
std::make_shared<TaskBuildIndex>(indexerThreadCount, indexerCommandList, storageProvider, fileRegisterStateData, multiProcess)
)
);
}
@@ -558,3 +549,15 @@ void Project::buildIndex(const std::set<FilePath>& filesToClean, bool fullRefres
Task::dispatch(taskSequential);
}
bool Project::hasCxxSourceGroup() const
{
for (std::shared_ptr<SourceGroup> sourceGroup: m_sourceGroups)
{
if (sourceGroup->getLanguage() == LANGUAGE_C || sourceGroup->getLanguage() == LANGUAGE_CPP)
{
return true;
}
}
return false;
}
+2
View File
@@ -49,6 +49,8 @@ private:
void buildIndex(const std::set<FilePath>& filesToClean, bool fullRefresh, bool preprocessorOnly);
bool hasCxxSourceGroup() const;
std::shared_ptr<ProjectSettings> m_settings;
StorageAccessProxy* const m_storageAccessProxy;
@@ -119,7 +119,7 @@ void QtProjectWizzardContentPreferences::populate(QGridLayout* layout, int& row)
row++;
// multi process indexing
m_multiProcessIndexing = addCheckBox("Multi process indexing", "Use processes instead of threads for indexing.",
m_multiProcessIndexing = addCheckBox("Multi process C/C++ indexing", "Use processes instead of threads for C/C++ indexing.",
"Using processes instead of threads prevents the application from crashing on unforseen exceptions during indexing.",
layout, row);
@@ -29,8 +29,9 @@ void JavaEnvironmentFactory::createInstance(std::string classPath, std::string&
std::function<jint (JavaVM**, void**, void*)> createInstanceFunction;
const FilePath javaPath(ApplicationSettings::getInstance()->getJavaPath());
createInstanceFunction = utility::loadFunctionFromLibrary<jint, JavaVM**, void**, void*>(
FilePath(ApplicationSettings::getInstance()->getJavaPath()),
javaPath,
"JNI_CreateJavaVM",
errorString
);