logic: multithreaded parsing

* modified the TaskParseCxx to be able to run multiple times in parallel
* made FileRegister threadsafe and changed a lot of its mechanisms
* added TaskGroupParallel that runs all children in parallel
* added TaskParseWrapper that acts as a decorator to execute some code before and after parsing.
* implemented task setup in project with 4 parsing threads
* removed SimpleTask as it was only used as interface for the LambdaTask
This commit is contained in:
malte_langkabel
2016-05-13 13:23:54 +02:00
parent 245cafdc7b
commit c61efbbcde
27 changed files with 535 additions and 317 deletions
+2 -2
View File
@@ -39,8 +39,8 @@ public:
ParserClient();
virtual ~ParserClient();
virtual void startParsingFile(const FilePath& filePath) = 0;
virtual void finishParsingFile(const FilePath& filePath) = 0;
virtual void startParsingFile() = 0;
virtual void finishParsingFile() = 0;
virtual void onError(const ParseLocation& location, const std::string& message, bool fatal) = 0;
+3 -3
View File
@@ -25,12 +25,12 @@ void ParserClientImpl::resetStorage()
m_storage.reset();
}
void ParserClientImpl::startParsingFile(const FilePath& filePath)
void ParserClientImpl::startParsingFile()
{
m_nodeIdsToMemberEdgeIds.clear();
m_nodeIdsToMemberEdgeIds.clear(); // remove this when one parserclient is created per file
}
void ParserClientImpl::finishParsingFile(const FilePath& filePath)
void ParserClientImpl::finishParsingFile()
{
}
+2 -2
View File
@@ -18,8 +18,8 @@ public:
void setStorage(std::shared_ptr<IntermediateStorage> storage);
void resetStorage();
virtual void startParsingFile(const FilePath& filePath);
virtual void finishParsingFile(const FilePath& filePath);
virtual void startParsingFile();
virtual void finishParsingFile();
virtual void onError(const ParseLocation& location, const std::string& message, bool fatal);
+8 -11
View File
@@ -2,6 +2,7 @@
#define TASK_PARSE_CXX_H
#include <memory>
#include <mutex>
#include <deque>
#include "data/parser/Parser.h"
@@ -10,7 +11,7 @@
#include "utility/TimePoint.h"
class PersistentStorage;
class FileManager;
class FileRegister;
class CxxParser;
namespace clang
@@ -25,15 +26,15 @@ class TaskParseCxx
: public Task
{
public:
static std::vector<FilePath> getSourceFilesFromCDB(const FilePath& compilationDatabasePath);
TaskParseCxx(
PersistentStorage* storage,
const FileManager* fileManager,
const Parser::Arguments& arguments,
const std::vector<FilePath>& files
std::shared_ptr<std::mutex> storageMutex,
std::shared_ptr<FileRegister> fileRegister,
const Parser::Arguments& arguments
);
static std::vector<FilePath> getSourceFilesFromCDB(const FilePath& compilationDatabasePath);
virtual void enter();
virtual TaskState update();
virtual void exit();
@@ -43,14 +44,10 @@ public:
private:
PersistentStorage* m_storage;
std::shared_ptr<std::mutex> m_storageMutex;
std::shared_ptr<CxxParser> m_parser;
std::shared_ptr<ParserClientImpl> m_parserClient;
const Parser::Arguments m_arguments;
const std::vector<FilePath> m_files;
std::deque<FilePath> m_sourcePaths;
TimePoint m_start;
bool m_isCDB;
std::shared_ptr<clang::tooling::JSONCompilationDatabase> m_cdb;
@@ -0,0 +1,41 @@
#ifndef TASK_PARSE_WRAPPER_H
#define TASK_PARSE_WRAPPER_H
#include <memory>
#include "data/parser/Parser.h"
#include "data/parser/ParserClientImpl.h"
#include "utility/scheduling/Task.h"
#include "utility/TimePoint.h"
class PersistentStorage;
class FileRegister;
class CxxParser;
class TaskParseWrapper
: public Task
{
public:
TaskParseWrapper(
std::shared_ptr<Task> child,
PersistentStorage* storage,
std::shared_ptr<FileRegister> fileRegister
);
virtual void enter();
virtual TaskState update();
virtual void exit();
virtual void interrupt();
virtual void revert();
private:
std::shared_ptr<Task> m_child;
PersistentStorage* m_storage;
std::shared_ptr<FileRegister> m_fileRegister;
TimePoint m_start;
};
#endif // TASK_PARSE_WRAPPER_H