logic: reduced waiting time when interrupting indexer processes

* made multiprocess AST traversal interruptible again
* removed const variables that define sleep times for threads
This commit is contained in:
mlangkabel
2018-09-21 17:19:03 +02:00
parent 593e075399
commit 951256c07b
44 changed files with 244 additions and 187 deletions
+15 -3
View File
@@ -1,19 +1,31 @@
#include "IndexerJava.h"
#include "IndexerCommandJava.h"
#include "ParserClientImpl.h"
#include "IndexerStateInfo.h"
#include "JavaParser.h"
#include "ParserClientImpl.h"
IndexerJava::IndexerJava()
: m_indexerStateInfo(std::make_shared<IndexerStateInfo>())
{
m_indexerStateInfo->indexingInterrupted = false;
}
IndexerJava::~IndexerJava()
{
JavaParser::clearCaches();
}
void IndexerJava::interrupt()
{
m_indexerStateInfo->indexingInterrupted = true;
}
std::shared_ptr<IntermediateStorage> IndexerJava::doIndex(std::shared_ptr<IndexerCommandJava> indexerCommand)
{
std::shared_ptr<ParserClientImpl> parserClient = std::make_shared<ParserClientImpl>();
std::shared_ptr<JavaParser> parser = std::make_shared<JavaParser>(parserClient);
std::shared_ptr<JavaParser> parser = std::make_shared<JavaParser>(parserClient, m_indexerStateInfo);
std::shared_ptr<IntermediateStorage> storage = std::make_shared<IntermediateStorage>();
parserClient->setStorage(storage);
@@ -31,7 +43,7 @@ std::shared_ptr<IntermediateStorage> IndexerJava::doIndex(std::shared_ptr<Indexe
storage->setFilesWithErrorsIncomplete();
}
if (interrupted())
if (m_indexerStateInfo->indexingInterrupted)
{
return std::shared_ptr<IntermediateStorage>();
}
+9 -1
View File
@@ -3,14 +3,22 @@
#include <memory>
#include "IndexerCommandJava.h"
#include "Indexer.h"
#include "IndexerCommandJava.h"
struct IndexerStateInfo;
class IndexerJava: public Indexer<IndexerCommandJava>
{
public:
IndexerJava();
virtual ~IndexerJava();
void interrupt() override;
private:
std::shared_ptr<IntermediateStorage> doIndex(std::shared_ptr<IndexerCommandJava> indexerCommand) override;
std::shared_ptr<IndexerStateInfo> m_indexerStateInfo;
};
#endif // INDEXER_JAVA_H
+10 -8
View File
@@ -2,14 +2,15 @@
#include <jni.h>
#include "NameHierarchy.h"
#include "JavaEnvironmentFactory.h"
#include "ParseLocation.h"
#include "ReferenceKind.h"
#include "ParserClient.h"
#include "ApplicationSettings.h"
#include "TextAccess.h"
#include "IndexerStateInfo.h"
#include "JavaEnvironmentFactory.h"
#include "NameHierarchy.h"
#include "ParseLocation.h"
#include "ParserClient.h"
#include "ReferenceKind.h"
#include "ResourcePaths.h"
#include "TextAccess.h"
#include "utilityJava.h"
#include "utilityString.h"
@@ -29,8 +30,9 @@ void JavaParser::clearCaches()
}
}
JavaParser::JavaParser(std::shared_ptr<ParserClient> client)
JavaParser::JavaParser(std::shared_ptr<ParserClient> client, std::shared_ptr<IndexerStateInfo> indexerStateInfo)
: Parser(client)
, m_indexerStateInfo(indexerStateInfo)
, m_id(s_nextParserId++)
{
const std::string errorString = utility::prepareJavaEnvironment();
@@ -140,7 +142,7 @@ std::mutex JavaParser::s_parsersMutex;
bool JavaParser::doGetInterrupted()
{
return m_interruptCounter.getCount() > 0;
return m_indexerStateInfo->indexingInterrupted;
}
void JavaParser::doLogInfo(jstring jInfo)
+6 -6
View File
@@ -5,12 +5,12 @@
#include <mutex>
#include <string>
#include "IndexerCommandJava.h"
#include "Parser.h"
#include "JavaEnvironment.h"
#include "FilePath.h"
#include "IndexerCommandJava.h"
#include "IndexerStateInfo.h"
#include "JavaEnvironment.h"
#include "logging.h"
#include "MessageInterruptTasksCounter.h"
#include "Parser.h"
struct JNIEnv_;
typedef JNIEnv_ JNIEnv;
@@ -35,7 +35,7 @@ class JavaParser: public Parser
public:
static void clearCaches();
JavaParser(std::shared_ptr<ParserClient> client);
JavaParser(std::shared_ptr<ParserClient> client, std::shared_ptr<IndexerStateInfo> indexerStateInfo);
~JavaParser();
void buildIndex(std::shared_ptr<IndexerCommandJava> indexerCommand);
@@ -231,7 +231,7 @@ private:
const int m_id;
FilePath m_currentFilePath;
MessageInterruptTasksCounter m_interruptCounter;
std::shared_ptr<IndexerStateInfo> m_indexerStateInfo;
};
#endif // JAVA_PARSER_H