data: indexer processes

* TaskBuildIndex starts seperate indexer processes and communicates via shared memory
* indexer processes get restarted if they fail
* indexer processes are killed when the app closes or crashes
* added utility class SharedMemory to allocate and access shared memory, providing basic data structures
* added SharedMemoryGarbageCollector for keeping track of running instances and cleaning up shared memory in case of a crash
* show errors for source files that crashed during indexing
* added basic exception handling to task scheduling
* added option to turn off processes and use threads in preferences, but still use shared memory

fortune cookie message = Good news from someone dear is coming soon.
This commit is contained in:
Eberhard Graether
2017-05-04 15:50:59 +02:00
parent 9beea94fd8
commit 706119ebcc
109 changed files with 3351 additions and 1261 deletions
+56 -3
View File
@@ -6,7 +6,15 @@
#include "utility/utilityString.h"
std::string utility::executeProcess(const std::string& command, const std::string& workingDirectory)
#include <iostream>
namespace utility
{
std::mutex s_runningProcessesMutex;
std::set<QProcess*> s_runningProcesses;
}
std::string utility::executeProcess(const std::string& command, const std::string& workingDirectory, int timeout)
{
QProcess process;
process.setProcessChannelMode(QProcess::MergedChannels);
@@ -16,8 +24,18 @@ std::string utility::executeProcess(const std::string& command, const std::strin
process.setWorkingDirectory(workingDirectory.c_str());
}
process.start(command.c_str());
process.waitForFinished();
{
std::lock_guard<std::mutex> lock(s_runningProcessesMutex);
process.start(command.c_str());
s_runningProcesses.insert(&process);
}
process.waitForFinished(timeout);
{
std::lock_guard<std::mutex> lock(s_runningProcessesMutex);
s_runningProcesses.erase(&process);
}
std::string processoutput = process.readAll().toStdString();
process.close();
processoutput = utility::trim(processoutput);
@@ -25,6 +43,41 @@ std::string utility::executeProcess(const std::string& command, const std::strin
return processoutput;
}
int utility::executeProcessAndGetExitCode(const std::string& command, const std::string& workingDirectory, int timeout)
{
QProcess process;
if (!workingDirectory.empty())
{
process.setWorkingDirectory(workingDirectory.c_str());
}
{
std::lock_guard<std::mutex> lock(s_runningProcessesMutex);
process.start(command.c_str());
s_runningProcesses.insert(&process);
}
process.waitForFinished(timeout);
{
std::lock_guard<std::mutex> lock(s_runningProcessesMutex);
s_runningProcesses.erase(&process);
}
int exitCode = process.exitCode();
process.close();
return exitCode;
}
void utility::killRunningProcesses()
{
std::lock_guard<std::mutex> lock(s_runningProcessesMutex);
for (QProcess* process : s_runningProcesses)
{
process->kill();
}
}
ApplicationArchitectureType utility::getApplicationArchitectureType()
{
#ifdef Q_PROCESSOR_X86_64