logic: added option to execute custom indexer commands in parallel

This commit is contained in:
mlangkabel
2019-01-21 13:28:51 +01:00
parent 85bd0d39c3
commit 3eb9211520
10 changed files with 289 additions and 60 deletions
@@ -1,6 +1,7 @@
#ifndef TASK_EXECUTE_CUSTOM_COMMANDS_H
#define TASK_EXECUTE_CUSTOM_COMMANDS_H
#include <set>
#include <vector>
#include "FilePath.h"
@@ -10,6 +11,7 @@
#include "MessageListener.h"
class DialogView;
class IndexerCommandCustom;
class IndexerCommandProvider;
class PersistentStorage;
@@ -22,6 +24,7 @@ public:
std::unique_ptr<IndexerCommandProvider> indexerCommandProvider,
std::shared_ptr<PersistentStorage> storage,
std::shared_ptr<DialogView> dialogView,
int indexerThreadCount,
const FilePath& projectDirectory);
private:
@@ -32,13 +35,24 @@ private:
void handleMessage(MessageIndexingInterrupted* message) override;
void executeParallelIndexerCommands(int threadId, std::shared_ptr<Blackboard> blackboard);
void runIndexerCommand(std::shared_ptr<IndexerCommandCustom> indexerCommand, std::shared_ptr<Blackboard> blackboard);
std::unique_ptr<IndexerCommandProvider> m_indexerCommandProvider;
std::shared_ptr<PersistentStorage> m_storage;
std::shared_ptr<DialogView> m_dialogView;
const int m_indexerThreadCount;
const FilePath m_projectDirectory;
TimeStamp m_start;
bool m_interrupted = false;
int m_indexerCommandCount;
std::vector<std::shared_ptr<IndexerCommandCustom>> m_serialCommands;
std::vector<std::shared_ptr<IndexerCommandCustom>> m_parallelCommands;
std::mutex m_parallelCommandsMutex;
FilePath m_targetDatabaseFilePath;
std::set<FilePath> m_sourceDatabaseFilePaths;
std::mutex m_sourceDatabaseFilePathsMutex;
};
#endif // TASK_EXECUTE_CUSTOM_COMMANDS_H