3#include <condition_variable>
23 virtual void Execute() = 0;
32 void ExecuteTask(
Task* task,
int thread_id);
33 void ExecuteTask(
Task* task);
34 void ExecuteTaskSet(std::function<
Task*(
int)> task_set,
int num);
35 void ExecuteTaskSet(std::function<
Task*(
int)> task_set, std::function<
int(
int)> thread_id,
int num);
36 void BlockUntilCompletion(
int thread_id);
37 void BlockUntilCompletion();
41 int smart_index(
int ix);
54 m_sub_queue =
nullptr;
58 m_sub_queue = sub_queue;
76 std::vector<Task*> m_queue;
102 std::thread m_thread;
103 std::condition_variable m_internal_barrier;
104 std::condition_variable m_external_barrier;
107 enum thread_state {IDLE, EXECUTING} m_state;
115 std::vector<WorkUnit*> m_WorkUnit;
117 bool m_DestructorCalled;
122 bool m_hyperthreading_core_merge;
Definition: AsynchronousTask.h:20
Core bound thread unit with a task queue.
Definition: AsynchronousTask.h:82
void setCpuMask(size_t cpu_mask)
bind thread to the cpu-cores specified by cpu_mask
void ThreadLoop()
"semi-infinite" loop. pop task from queue and execute. if no task, go idle until new task is added.
void TerminateUnit()
terminates thread work loop, empties queue, and joins thread.
void AddToQueue(Task *t)
add this task to the task queue and return. Tasks are executed asynchronously in a strict FIFO order.
WorkUnit(size_t cpu_mask, mutex_queue *sub_queue)
initialize thread and bind to the cores specified by cpu_mask
void NudgeThread()
wakes thread from idle
void WaitUntilIdle()
blocks until thread is idle
if task are ordered roughly according to decreasing size, smart_index will return a 'good' core alloc...
Definition: AsynchronousTask.h:51
bool isEmpty()
threadsafe: is the queue (including sub_queues) empty?
void KillAllTasks()
threadsafe: remove all tasks from queue
Task * pop()
threadsafe: pop task from queue
void push(Task *t)
threadsafe: push task to queue
Definition: AsynchronousTask.h:15
Definition: CollisionManager.h:6