* 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.
52 lines
1.1 KiB
C++
52 lines
1.1 KiB
C++
#ifndef TASK_SCHEDULER_H
|
|
#define TASK_SCHEDULER_H
|
|
|
|
#include <memory>
|
|
#include <mutex>
|
|
#include <deque>
|
|
|
|
#include "utility/messaging/MessageListener.h"
|
|
#include "utility/messaging/type/MessageInterruptTasks.h"
|
|
#include "utility/scheduling/Task.h"
|
|
#include "utility/scheduling/TaskRunner.h"
|
|
|
|
class TaskScheduler
|
|
{
|
|
public:
|
|
static std::shared_ptr<TaskScheduler> getInstance();
|
|
|
|
void pushTask(std::shared_ptr<Task> task);
|
|
void pushNextTask(std::shared_ptr<Task> task);
|
|
|
|
void startSchedulerLoopThreaded();
|
|
void startSchedulerLoop();
|
|
void stopSchedulerLoop();
|
|
|
|
bool loopIsRunning() const;
|
|
bool hasTasksQueued() const;
|
|
|
|
void terminateRunningTasks();
|
|
|
|
private:
|
|
static std::shared_ptr<TaskScheduler> s_instance;
|
|
|
|
TaskScheduler();
|
|
TaskScheduler(const TaskScheduler&);
|
|
void operator=(const TaskScheduler&);
|
|
|
|
void processTasks();
|
|
|
|
|
|
bool m_loopIsRunning;
|
|
bool m_threadIsRunning;
|
|
bool m_terminateRunningTasks;
|
|
|
|
std::deque<std::shared_ptr<TaskRunner>> m_taskRunners;
|
|
|
|
mutable std::mutex m_tasksMutex;
|
|
mutable std::mutex m_loopMutex;
|
|
mutable std::mutex m_threadMutex;
|
|
};
|
|
|
|
#endif // TASK_SCHEDULER_H
|