8 typedef struct taskqueue_task_s
\r
10 // doubly linked list
\r
11 struct taskqueue_task_s * volatile prev;
\r
12 struct taskqueue_task_s * volatile next;
\r
14 // if not NULL, this task must be done before this one will dequeue (faster than simply Yielding immediately)
\r
15 struct taskqueue_task_s *preceding;
\r
17 // see TaskQueue_IsDone() to use proper atomics to poll done status
\r
18 volatile int started;
\r
21 // function to call, and parameters for it to use
\r
22 void(*func)(struct taskqueue_task_s *task);
\r
27 unsigned int yieldcount; // number of times this task has been requeued
\r
31 // immediately execute any pending tasks if threading is disabled (or if force is true)
\r
32 // TRY NOT TO USE THIS IF POSSIBLE - poll task->done instead.
\r
33 void TaskQueue_Execute(qboolean force);
\r
35 // queue the tasks to be executed, or executes them immediately if threading is disabled.
\r
36 void TaskQueue_Enqueue(int numtasks, taskqueue_task_t *tasks);
\r
38 // if the task can not be completed due yet to preconditions, just enqueue it again...
\r
39 void TaskQueue_Yield(taskqueue_task_t *t);
\r
41 // polls for status of task and returns the result immediately - use this instead of checking ->done directly, as this uses atomics
\r
42 qboolean TaskQueue_IsDone(taskqueue_task_t *t);
\r
44 // polls for status of task and waits for it to be done
\r
45 void TaskQueue_WaitForTaskDone(taskqueue_task_t *t);
\r
47 // convenience function for setting up a task structure. Does not do the Enqueue, just fills in the struct.
\r
48 void TaskQueue_Setup(taskqueue_task_t *t, taskqueue_task_t *preceding, void(*func)(taskqueue_task_t *), size_t i0, size_t i1, void *p0, void *p1);
\r
50 // general purpose tasks
\r
51 // t->i[0] = number of tasks in array
\r
52 // t->p[0] = array of taskqueue_task_t to check
\r
53 void TaskQueue_Task_CheckTasksDone(taskqueue_task_t *t);
\r
55 void TaskQueue_Init(void);
\r
56 void TaskQueue_Shutdown(void);
\r
57 void TaskQueue_Frame(qboolean shutdown);
\r