* TaskBuildIndex starts seperate indexer processes and communicates via shared memory * indexer processes get restarted if they fail * indexer processes are killed when the app closes or crashes * added utility class SharedMemory to allocate and access shared memory, providing basic data structures * added SharedMemoryGarbageCollector for keeping track of running instances and cleaning up shared memory in case of a crash * show errors for source files that crashed during indexing * added basic exception handling to task scheduling * added option to turn off processes and use threads in preferences, but still use shared memory fortune cookie message = Good news from someone dear is coming soon.
56 lines
798 B
C++
56 lines
798 B
C++
#include "utility/scheduling/TaskRunner.h"
|
|
|
|
#include "utility/logging/logging.h"
|
|
#include "utility/scheduling/TaskScheduler.h"
|
|
|
|
TaskRunner::TaskRunner(std::shared_ptr<Task> task)
|
|
: m_task(task)
|
|
, m_reset(false)
|
|
{
|
|
}
|
|
|
|
TaskRunner::~TaskRunner()
|
|
{
|
|
}
|
|
|
|
Task::TaskState TaskRunner::update(std::shared_ptr<Blackboard> blackboard)
|
|
{
|
|
try
|
|
{
|
|
if (m_reset)
|
|
{
|
|
m_task->reset(blackboard);
|
|
m_reset = false;
|
|
}
|
|
|
|
return m_task->update(blackboard);
|
|
}
|
|
catch (std::exception& e)
|
|
{
|
|
LOG_ERROR(e.what());
|
|
}
|
|
catch (...)
|
|
{
|
|
LOG_ERROR("Unknown exception thrown during task running");
|
|
}
|
|
|
|
TaskScheduler::getInstance()->terminateRunningTasks();
|
|
return Task::STATE_FAILURE;
|
|
}
|
|
|
|
void TaskRunner::reset()
|
|
{
|
|
m_reset = true;
|
|
}
|
|
|
|
void TaskRunner::terminate()
|
|
{
|
|
if (m_task)
|
|
{
|
|
m_task->terminate();
|
|
}
|
|
}
|
|
|
|
|
|
|