5 #ifndef TASKSCHEDULER_H 6 #define TASKSCHEDULER_H 8 #include <boost/thread.hpp> 9 #include <boost/thread/condition.hpp> 10 #include <boost/function.hpp> 33 typedef boost::function<void(void)> TaskProc;
37 inline State getState()
const {
return m_state; }
40 volatile State m_state;
51 void add(
const Task::TaskProc &proc,
TaskScheduler &scheduler);
52 uint32_t getRemainingUnfinishedTasks()
const {
return m_remainingUnfinishedTasks; }
54 volatile uint32_t m_remainingUnfinishedTasks;
55 std::vector<Task*> m_tasks;
63 void add(
const Task::TaskProc &proc,
TaskScheduler &scheduler);
72 static void Init(
unsigned helperThreads);
73 static void Shutdown();
77 void waitFor(
Task *task);
80 static TaskScheduler &
get() {
if (m_mainInstance != NULL)
return *m_mainInstance;
throw std::runtime_error(
"TaskScheduler not initialized yet!"); }
82 void scheduleTask(
Task *task);
87 volatile bool m_shutdown;
88 typedef std::list<Task*> TaskList;
89 TaskList m_scheduledTasks;
91 #define TASK_SCHEDULER_USE_KERNEL 93 #ifdef TASK_SCHEDULER_USE_KERNEL 94 boost::condition m_wakeupCondition;
95 boost::mutex m_wakeupMutex;
97 boost::condition m_waitForCondition;
98 boost::condition m_groupFinishedCondition;
99 boost::mutex m_waitForMutex;
101 volatile uint32_t m_taskListLock;
102 volatile uint32_t m_numTasksEnqueued;
106 std::vector<boost::thread*> m_helperThreads;
108 void helperThreadOperate();
114 #endif // TASKSCHEDULER_H Definition: CameraPathEvaluation.cpp:10