logic: Fixed and improved indexing interruption (issue #634)

* Fixed indexing can be interrupted when dialog hidden
* Clear intermediate storages when interrupting
* Abort waiting for less queued storages when indexing interrupted
* Don't index another file when indexing was already interrupted
* Moved indexing interrupted progress dialog to TaskBuildIndex
* Use MessageIndexingInterrupted instead of MessageInterruptTasks
This commit is contained in:
Eberhard Graether
2018-11-23 15:33:20 +01:00
parent 308954635e
commit 267d6b2eb7
17 changed files with 67 additions and 67 deletions
+1 -1
View File
@@ -455,6 +455,7 @@ add_files(
utility/messaging/type/history/MessageHistoryUndo.h
utility/messaging/type/indexing/MessageIndexingFinished.h
utility/messaging/type/indexing/MessageIndexingInterrupted.h
utility/messaging/type/indexing/MessageIndexingShowDialog.h
utility/messaging/type/indexing/MessageIndexingStarted.h
utility/messaging/type/indexing/MessageIndexingStatus.h
@@ -494,7 +495,6 @@ add_files(
utility/messaging/type/MessageGraphNodeHide.h
utility/messaging/type/MessageGraphNodeMove.h
utility/messaging/type/MessageIDECreateCDB.h
utility/messaging/type/MessageInterruptTasks.h
utility/messaging/type/MessageLoadProject.h
utility/messaging/type/MessageLogFilterChanged.h
utility/messaging/type/MessageMoveIDECursor.h
+5
View File
@@ -41,3 +41,8 @@ void TaskInjectStorage::doExit(std::shared_ptr<Blackboard> blackboard)
void TaskInjectStorage::doReset(std::shared_ptr<Blackboard> blackboard)
{
}
void TaskInjectStorage::handleMessage(MessageIndexingInterrupted* message)
{
m_storageProvider->clear();
}
+5
View File
@@ -3,6 +3,8 @@
#include <vector>
#include "MessageIndexingInterrupted.h"
#include "MessageListener.h"
#include "Task.h"
class Storage;
@@ -10,6 +12,7 @@ class StorageProvider;
class TaskInjectStorage
: public Task
, public MessageListener<MessageIndexingInterrupted>
{
public:
TaskInjectStorage(
@@ -23,6 +26,8 @@ private:
void doExit(std::shared_ptr<Blackboard> blackboard) override;
void doReset(std::shared_ptr<Blackboard> blackboard) override;
void handleMessage(MessageIndexingInterrupted* message) override;
std::shared_ptr<StorageProvider> m_storageProvider;
std::weak_ptr<Storage> m_target;
};
+11 -8
View File
@@ -125,7 +125,10 @@ void TaskBuildIndex::doExit(std::shared_ptr<Blackboard> blackboard)
}
m_processThreads.clear();
while (fetchIntermediateStorages(blackboard));
if (!m_interrupted)
{
while (fetchIntermediateStorages(blackboard));
}
std::vector<FilePath> crashedFiles = m_interprocessIndexingStatusManager.getCrashedSourceFilePaths();
if (crashedFiles.size())
@@ -156,14 +159,14 @@ void TaskBuildIndex::terminate()
utility::killRunningProcesses();
}
void TaskBuildIndex::handleMessage(MessageInterruptTasks* message)
void TaskBuildIndex::handleMessage(MessageIndexingInterrupted* message)
{
if (!m_dialogView->dialogsHidden())
{
LOG_INFO("sending indexer interrupt command.");
m_interprocessIndexingStatusManager.setIndexingInterrupted(true);
m_interrupted = true;
}
LOG_INFO("sending indexer interrupt command.");
m_interprocessIndexingStatusManager.setIndexingInterrupted(true);
m_interrupted = true;
m_dialogView->showUnknownProgressDialog(L"Interrupting Indexing", L"Waiting for indexer\nthreads to finish");
}
void TaskBuildIndex::runIndexerProcess(int processId, const std::wstring& logFilePath)
+3 -3
View File
@@ -4,7 +4,7 @@
#include <thread>
#include "MessageListener.h"
#include "MessageInterruptTasks.h"
#include "MessageIndexingInterrupted.h"
#include "Task.h"
#include "InterprocessIndexerCommandManager.h"
@@ -17,7 +17,7 @@ class IndexerCommandList;
class TaskBuildIndex
: public Task
, public MessageListener<MessageInterruptTasks>
, public MessageListener<MessageIndexingInterrupted>
{
public:
TaskBuildIndex(
@@ -35,7 +35,7 @@ protected:
void doReset(std::shared_ptr<Blackboard> blackboard) override;
void terminate() override;
void handleMessage(MessageInterruptTasks* message) override;
void handleMessage(MessageIndexingInterrupted* message) override;
void runIndexerProcess(int processId, const std::wstring& logFilePath);
void runIndexerThread(int processId);
@@ -106,7 +106,7 @@ void TaskFillIndexerCommandsQueue::terminate()
m_interrupted = true;
}
void TaskFillIndexerCommandsQueue::handleMessage(MessageInterruptTasks* message)
void TaskFillIndexerCommandsQueue::handleMessage(MessageIndexingInterrupted* message)
{
std::lock_guard<std::mutex> lock(m_commandsMutex);
@@ -4,7 +4,7 @@
#include <queue>
#include "MessageListener.h"
#include "MessageInterruptTasks.h"
#include "MessageIndexingInterrupted.h"
#include "Task.h"
#include "InterprocessIndexerCommandManager.h"
@@ -13,7 +13,7 @@ class IndexerCommandProvider;
class TaskFillIndexerCommandsQueue
: public Task
, public MessageListener<MessageInterruptTasks>
, public MessageListener<MessageIndexingInterrupted>
{
public:
TaskFillIndexerCommandsQueue(
@@ -29,7 +29,7 @@ protected:
void doReset(std::shared_ptr<Blackboard> blackboard) override;
void terminate() override;
void handleMessage(MessageInterruptTasks* message) override;
void handleMessage(MessageIndexingInterrupted* message) override;
bool fillCommandQueue();
@@ -60,7 +60,7 @@ void InterprocessIndexer::work()
LOG_INFO(std::to_wstring(m_processId) + L" fetched indexer command for \"" + indexerCommand->getSourceFilePath().wstr() + L"\"");
LOG_INFO(std::to_wstring(m_processId) + L" indexer commands left: " + std::to_wstring(m_interprocessIndexerCommandManager.indexerCommandCount() + 1));
while (true)
while (updaterThreadRunning)
{
const size_t storageCount = m_interprocessIntermediateStorageManager.getIntermediateStorageCount();
if (storageCount < 2)
@@ -73,6 +73,11 @@ void InterprocessIndexer::work()
std::this_thread::sleep_for(std::chrono::milliseconds(200));
}
if (!updaterThreadRunning)
{
break;
}
LOG_INFO_STREAM(<< m_processId << " updating indexer status with currently indexed filepath");
m_interprocessIndexingStatusManager.startIndexingSourceFile(indexerCommand->getSourceFilePath());
+6
View File
@@ -8,6 +8,12 @@ int StorageProvider::getStorageCount() const
return m_storages.size();
}
void StorageProvider::clear()
{
std::lock_guard<std::mutex> lock(m_storagesMutex);
return m_storages.clear();
}
void StorageProvider::insert(std::shared_ptr<IntermediateStorage> storage)
{
const std::size_t storageSize = storage->getSourceLocationCount();
+2
View File
@@ -11,6 +11,8 @@ class StorageProvider
public:
int getStorageCount() const;
void clear();
void insert(std::shared_ptr<IntermediateStorage> storage);
// returns empty shared_ptr if no storages available
@@ -1,21 +0,0 @@
#ifndef MESSAGE_INTERRUPT_TASKS_H
#define MESSAGE_INTERRUPT_TASKS_H
#include "Message.h"
class MessageInterruptTasks:
public Message<MessageInterruptTasks>
{
public:
MessageInterruptTasks()
{
setSendAsTask(false);
}
static const std::string getStaticType()
{
return "MessageInterruptTasks";
}
};
#endif // MESSAGE_INTERRUPT_TASKS_H
@@ -0,0 +1,16 @@
#ifndef MESSAGE_INDEXING_INTERRUPTED_H
#define MESSAGE_INDEXING_INTERRUPTED_H
#include "Message.h"
class MessageIndexingInterrupted
: public Message<MessageIndexingInterrupted>
{
public:
static const std::string getStaticType()
{
return "MessageIndexingInterrupted";
}
};
#endif // MESSAGE_INDEXING_INTERRUPTED_H