logic: reimplemented task system to abort ast visiting

* reimplemented interrupting TaskParseCxx by adding a listener for the MessageInterruptTask and returning a failure status code on update. This cancels the parent sequence task which results in the indexed items not getting inserted into the persistent storage
* removed the capability for interrupting from TaskScheduler
* changed task system to be closer to the standard behavior tree implementation
* changed task system to accommodate the 3 status return types: Running, Success and Failure
* made TaskGroupSequential fail once a member task fails
* made TaskGroupParallel fail once a member task fails
* split TaskParse... into one task for indexing and one task for injecting
* added TaskRunner that handles updating and resetting the managed task
* fixed numbers that are shown as parsed file count in indexing ui
* fixed deadlock that originated from interaction between TaskScheduler and MessageQueue (one thread wanted to destroy a message listener on a task while the other one wanted to send as message as a task)
This commit is contained in:
malte_langkabel
2016-09-07 14:39:34 +02:00
parent cbcf56f7dc
commit 4f302b0d1d
48 changed files with 651 additions and 678 deletions
+2 -5
View File
@@ -8,16 +8,15 @@
#include "utility/messaging/MessageListener.h"
#include "utility/messaging/type/MessageInterruptTasks.h"
#include "utility/scheduling/Task.h"
#include "utility/scheduling/TaskRunner.h"
class TaskScheduler
: public MessageListener<MessageInterruptTasks>
{
public:
static std::shared_ptr<TaskScheduler> getInstance();
void pushTask(std::shared_ptr<Task> task);
void pushNextTask(std::shared_ptr<Task> task);
void interruptCurrentTask();
void startSchedulerLoopThreaded();
void startSchedulerLoop();
@@ -35,13 +34,11 @@ private:
void processTasks();
virtual void handleMessage(MessageInterruptTasks* message);
bool m_loopIsRunning;
bool m_threadIsRunning;
std::deque<std::shared_ptr<Task>> m_tasks;
bool m_interruptTask;
std::deque<std::shared_ptr<TaskRunner>> m_taskRunners;
mutable std::mutex m_tasksMutex;
mutable std::mutex m_loopMutex;