24# include <tbb/blocked_range.h>
25# include <tbb/task_arena.h>
26# include <tbb/task_group.h>
76 other.taskdata =
nullptr;
77 other.free_taskdata =
false;
78 other.freedata =
nullptr;
85#if (defined(WITH_TBB) && TBB_INTERFACE_VERSION_MAJOR < 10) || \
86 (defined(_MSC_VER) && defined(__clang__) && TBB_INTERFACE_VERSION_MAJOR < 12)
94 ((
Task &)other).pool =
nullptr;
95 ((
Task &)other).run =
nullptr;
96 ((
Task &)other).taskdata =
nullptr;
97 ((
Task &)other).free_taskdata =
false;
98 ((
Task &)other).freedata =
nullptr;
115class TBBTaskGroup :
public tbb::task_group {
119# if TBB_INTERFACE_VERSION_MAJOR >= 12
127 my_context.set_priority(tbb::priority_low);
130 my_context.set_priority(tbb::priority_normal);
191 new (&pool->
tbb_group) TBBTaskGroup(priority);
203 new (task_mem)
Task(std::move(task));
209 std::atomic_thread_fence(std::memory_order_release);
265 return tbb::is_current_task_group_canceling();
311 new (task_mem)
Task(std::move(task));
433 switch (pool->
type) {
456 Task task(pool, run, taskdata, free_taskdata, freedata);
458 switch (pool->
type) {
473 switch (pool->
type) {
488 switch (pool->
type) {
503 switch (pool->
type) {
512 BLI_assert_msg(0,
"BLI_task_pool_canceled: Control flow should not come here!");
#define BLI_assert_msg(a, msg)
void * BLI_mempool_alloc(BLI_mempool *pool) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(1)
void BLI_mempool_iternew(BLI_mempool *pool, BLI_mempool_iter *iter) ATTR_NONNULL()
void * BLI_mempool_iterstep(BLI_mempool_iter *iter) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
BLI_mempool * BLI_mempool_create(unsigned int esize, unsigned int elem_num, unsigned int pchunk, unsigned int flag) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
void BLI_mempool_destroy(BLI_mempool *pool) ATTR_NONNULL(1)
void BLI_mempool_clear(BLI_mempool *pool) ATTR_NONNULL(1)
int BLI_task_scheduler_num_threads(void)
void(* TaskFreeFunction)(TaskPool *__restrict pool, void *taskdata)
void BLI_thread_queue_push(ThreadQueue *queue, void *work)
void * BLI_thread_queue_pop(ThreadQueue *queue)
void BLI_mutex_end(ThreadMutex *mutex)
ThreadQueue * BLI_thread_queue_init(void)
void BLI_threadpool_remove(struct ListBase *threadbase, void *callerdata)
void BLI_threadpool_init(struct ListBase *threadbase, void *(*do_thread)(void *), int tot)
void BLI_mutex_init(ThreadMutex *mutex)
void BLI_thread_queue_free(ThreadQueue *queue)
void BLI_threadpool_end(struct ListBase *threadbase)
void BLI_thread_queue_nowait(ThreadQueue *queue)
void BLI_thread_queue_wait_finish(ThreadQueue *queue)
void BLI_threadpool_clear(struct ListBase *threadbase)
int BLI_available_threads(struct ListBase *threadbase)
void BLI_threadpool_insert(struct ListBase *threadbase, void *callerdata)
pthread_mutex_t ThreadMutex
These structs are the foundation for all linked lists in the library system.
Read Guarded memory(de)allocation.
Task & operator=(const Task &other)=delete
Task & operator=(Task &&other)=delete
Task(const Task &other)=delete
TaskFreeFunction freedata
Task(TaskPool *pool, TaskRunFunction run, void *taskdata, bool free_taskdata, TaskFreeFunction freedata)
void *(* MEM_mallocN)(size_t len, const char *str)
void MEM_freeN(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
ThreadQueue * background_queue
volatile bool is_suspended
tbb::task_group tbb_group
ListBase background_threads
volatile bool background_is_canceling
BLI_mempool * suspended_mempool
function< void(void)> TaskRunFunction
static void tbb_task_pool_run(TaskPool *pool, Task &&task)
static bool background_task_pool_canceled(TaskPool *pool)
static bool tbb_task_pool_canceled(TaskPool *pool)
TaskPool * BLI_task_pool_create_suspended(void *userdata, eTaskPriority priority)
static void tbb_task_pool_cancel(TaskPool *pool)
void * BLI_task_pool_user_data(TaskPool *pool)
static void background_task_pool_run(TaskPool *pool, Task &&task)
static void background_task_pool_work_and_wait(TaskPool *pool)
bool BLI_task_pool_current_canceled(TaskPool *pool)
TaskPool * BLI_task_pool_create_no_threads(void *userdata)
void BLI_task_pool_work_and_wait(TaskPool *pool)
void BLI_task_pool_cancel(TaskPool *pool)
static void background_task_pool_free(TaskPool *pool)
static void tbb_task_pool_work_and_wait(TaskPool *pool)
ThreadMutex * BLI_task_pool_user_mutex(TaskPool *pool)
static void tbb_task_pool_create(TaskPool *pool, eTaskPriority priority)
TaskPool * BLI_task_pool_create_background(void *userdata, eTaskPriority priority)
TaskPool * BLI_task_pool_create_background_serial(void *userdata, eTaskPriority priority)
TaskPool * BLI_task_pool_create(void *userdata, eTaskPriority priority)
static void * background_task_run(void *userdata)
static void background_task_pool_create(TaskPool *pool)
static void tbb_task_pool_free(TaskPool *pool)
static TaskPool * task_pool_create_ex(void *userdata, TaskPoolType type, eTaskPriority priority)
static void background_task_pool_cancel(TaskPool *pool)
void BLI_task_pool_free(TaskPool *pool)
@ TASK_POOL_TBB_SUSPENDED
@ TASK_POOL_BACKGROUND_SERIAL
void BLI_task_pool_push(TaskPool *pool, TaskRunFunction run, void *taskdata, bool free_taskdata, TaskFreeFunction freedata)