* 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)
48 lines
961 B
C++
48 lines
961 B
C++
#include "data/TaskRepeatWhileUnparsedSourceFilesAvailable.h"
|
|
|
|
#include "utility/file/FileRegister.h"
|
|
|
|
TaskRepeatWhileUnparsedSourceFilesAvailable::TaskRepeatWhileUnparsedSourceFilesAvailable(
|
|
std::shared_ptr<FileRegister> fileRegister
|
|
)
|
|
: m_fileRegister(fileRegister)
|
|
{
|
|
}
|
|
|
|
void TaskRepeatWhileUnparsedSourceFilesAvailable::setTask(std::shared_ptr<Task> task)
|
|
{
|
|
if (task)
|
|
{
|
|
m_taskRunner = std::make_shared<TaskRunner>(task);
|
|
}
|
|
}
|
|
|
|
void TaskRepeatWhileUnparsedSourceFilesAvailable::doEnter()
|
|
{
|
|
}
|
|
|
|
Task::TaskState TaskRepeatWhileUnparsedSourceFilesAvailable::doUpdate()
|
|
{
|
|
TaskState state = m_taskRunner->update();
|
|
|
|
if (state == Task::STATE_SUCCESS)
|
|
{
|
|
if(m_fileRegister->getUnparsedSourceFilePaths().size() != 0)
|
|
{
|
|
state = Task::STATE_RUNNING;
|
|
m_taskRunner->reset();
|
|
}
|
|
}
|
|
|
|
return state;
|
|
}
|
|
|
|
void TaskRepeatWhileUnparsedSourceFilesAvailable::doExit()
|
|
{
|
|
}
|
|
|
|
void TaskRepeatWhileUnparsedSourceFilesAvailable::doReset()
|
|
{
|
|
m_taskRunner->reset();
|
|
}
|