Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenlib/BLI_task.h
| Show First 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | typedef enum TaskPriority { | ||||
| TASK_PRIORITY_LOW, | TASK_PRIORITY_LOW, | ||||
| TASK_PRIORITY_HIGH, | TASK_PRIORITY_HIGH, | ||||
| } TaskPriority; | } TaskPriority; | ||||
| typedef struct TaskPool TaskPool; | typedef struct TaskPool TaskPool; | ||||
| typedef void (*TaskRunFunction)(TaskPool *__restrict pool, void *taskdata, int threadid); | typedef void (*TaskRunFunction)(TaskPool *__restrict pool, void *taskdata, int threadid); | ||||
| typedef void (*TaskFreeFunction)(TaskPool *__restrict pool, void *taskdata, int threadid); | typedef void (*TaskFreeFunction)(TaskPool *__restrict pool, void *taskdata, int threadid); | ||||
| TaskPool *BLI_task_pool_create(TaskScheduler *scheduler, void *userdata); | TaskPool *BLI_task_pool_create(TaskScheduler *scheduler, void *userdata, TaskPriority priority); | ||||
| TaskPool *BLI_task_pool_create_background(TaskScheduler *scheduler, void *userdata); | TaskPool *BLI_task_pool_create_background(TaskScheduler *scheduler, | ||||
| TaskPool *BLI_task_pool_create_suspended(TaskScheduler *scheduler, void *userdata); | void *userdata, | ||||
| TaskPriority priority); | |||||
| TaskPool *BLI_task_pool_create_suspended(TaskScheduler *scheduler, | |||||
| void *userdata, | |||||
| TaskPriority priority); | |||||
| void BLI_task_pool_free(TaskPool *pool); | void BLI_task_pool_free(TaskPool *pool); | ||||
| void BLI_task_pool_push_ex(TaskPool *pool, | |||||
| TaskRunFunction run, | |||||
| void *taskdata, | |||||
| bool free_taskdata, | |||||
| TaskFreeFunction freedata, | |||||
| TaskPriority priority); | |||||
| void BLI_task_pool_push(TaskPool *pool, | void BLI_task_pool_push(TaskPool *pool, | ||||
| TaskRunFunction run, | TaskRunFunction run, | ||||
| void *taskdata, | void *taskdata, | ||||
| bool free_taskdata, | bool free_taskdata, | ||||
| TaskPriority priority); | TaskFreeFunction freedata); | ||||
| void BLI_task_pool_push_from_thread(TaskPool *pool, | void BLI_task_pool_push_from_thread(TaskPool *pool, | ||||
| TaskRunFunction run, | TaskRunFunction run, | ||||
| void *taskdata, | void *taskdata, | ||||
| bool free_taskdata, | bool free_taskdata, | ||||
| TaskPriority priority, | TaskFreeFunction freedata, | ||||
| int thread_id); | int thread_id); | ||||
| /* work and wait until all tasks are done */ | /* work and wait until all tasks are done */ | ||||
| void BLI_task_pool_work_and_wait(TaskPool *pool); | void BLI_task_pool_work_and_wait(TaskPool *pool); | ||||
| /* work and wait until all tasks are done, then reset to the initial suspended state */ | /* work and wait until all tasks are done, then reset to the initial suspended state */ | ||||
| void BLI_task_pool_work_wait_and_reset(TaskPool *pool); | void BLI_task_pool_work_wait_and_reset(TaskPool *pool); | ||||
| /* cancel all tasks, keep worker threads running */ | /* cancel all tasks, keep worker threads running */ | ||||
| void BLI_task_pool_cancel(TaskPool *pool); | void BLI_task_pool_cancel(TaskPool *pool); | ||||
| /* for worker threads, test if canceled */ | /* for worker threads, test if canceled */ | ||||
| bool BLI_task_pool_canceled(TaskPool *pool); | bool BLI_task_pool_canceled(TaskPool *pool); | ||||
| /* optional userdata pointer to pass along to run function */ | /* optional userdata pointer to pass along to run function */ | ||||
| void *BLI_task_pool_userdata(TaskPool *pool); | void *BLI_task_pool_userdata(TaskPool *pool); | ||||
| /* optional mutex to use from run function */ | /* optional mutex to use from run function */ | ||||
| ThreadMutex *BLI_task_pool_user_mutex(TaskPool *pool); | ThreadMutex *BLI_task_pool_user_mutex(TaskPool *pool); | ||||
| /* Thread ID of thread that created the task pool. */ | |||||
| int BLI_task_pool_creator_thread_id(TaskPool *pool); | |||||
| /* Delayed push, use that to reduce thread overhead by accumulating | /* Delayed push, use that to reduce thread overhead by accumulating | ||||
| * all new tasks into local queue first and pushing it to scheduler | * all new tasks into local queue first and pushing it to scheduler | ||||
| * from within a single mutex lock. | * from within a single mutex lock. | ||||
| */ | */ | ||||
| void BLI_task_pool_delayed_push_begin(TaskPool *pool, int thread_id); | void BLI_task_pool_delayed_push_begin(TaskPool *pool, int thread_id); | ||||
| void BLI_task_pool_delayed_push_end(TaskPool *pool, int thread_id); | void BLI_task_pool_delayed_push_end(TaskPool *pool, int thread_id); | ||||
| /* Parallel for routines */ | /* Parallel for routines */ | ||||
| ▲ Show 20 Lines • Show All 147 Lines • Show Last 20 Lines | |||||