Blender V5.0
task_pool.cc File Reference
#include <atomic>
#include <cstdlib>
#include <memory>
#include <utility>
#include "MEM_guardedalloc.h"
#include "DNA_listBase.h"
#include "BLI_assert.h"
#include "BLI_mempool.h"
#include "BLI_task.h"
#include "BLI_threads.h"
#include "BLI_vector.hh"

Go to the source code of this file.

Classes

class  Task
class  TaskPool

Enumerations

enum  TaskPoolType {
  TASK_POOL_TBB , TASK_POOL_TBB_SUSPENDED , TASK_POOL_NO_THREADS , TASK_POOL_BACKGROUND ,
  TASK_POOL_BACKGROUND_SERIAL
}

Functions

TaskPoolBLI_task_pool_create (void *userdata, eTaskPriority priority)
TaskPoolBLI_task_pool_create_background (void *userdata, eTaskPriority priority)
TaskPoolBLI_task_pool_create_suspended (void *userdata, eTaskPriority priority)
TaskPoolBLI_task_pool_create_no_threads (void *userdata)
TaskPoolBLI_task_pool_create_background_serial (void *userdata, eTaskPriority priority)
void BLI_task_pool_free (TaskPool *pool)
void BLI_task_pool_push (TaskPool *pool, TaskRunFunction run, void *taskdata, bool free_taskdata, TaskFreeFunction freedata)
void BLI_task_pool_work_and_wait (TaskPool *pool)
void BLI_task_pool_cancel (TaskPool *pool)
bool BLI_task_pool_current_canceled (TaskPool *pool)
void * BLI_task_pool_user_data (TaskPool *pool)

Detailed Description

Task pool to run tasks in parallel.

Definition in file task_pool.cc.

Enumeration Type Documentation

◆ TaskPoolType

Enumerator
TASK_POOL_TBB 
TASK_POOL_TBB_SUSPENDED 
TASK_POOL_NO_THREADS 
TASK_POOL_BACKGROUND 
TASK_POOL_BACKGROUND_SERIAL 

Definition at line 149 of file task_pool.cc.

Function Documentation

◆ BLI_task_pool_cancel()

void BLI_task_pool_cancel ( TaskPool * pool)

Cancel all tasks, keep worker threads running.

Definition at line 540 of file task_pool.cc.

References TaskPool::cancel().

Referenced by filelist_cache_previews_clear(), and blender::ed::vse::preview_startjob().

◆ BLI_task_pool_create()

TaskPool * BLI_task_pool_create ( void * userdata,
eTaskPriority priority )

Regular task pool that immediately starts executing tasks as soon as they are pushed, either on the current or another thread.

Tasks will be executed as soon as they are added.

Definition at line 484 of file task_pool.cc.

References TASK_POOL_TBB.

Referenced by BKE_lib_override_library_main_operations_create(), BLI_task_parallel_mempool(), distribute_particles_on_dm(), do_sequence_proxy(), lineart_main_add_triangles(), lineart_main_load_geometries(), lineart_main_occlusion_begin(), blender::ed::vse::preview_startjob(), psys_cache_child_paths(), screen_opengl_render_init(), and start_prefetch_threads().

◆ BLI_task_pool_create_background()

TaskPool * BLI_task_pool_create_background ( void * userdata,
eTaskPriority priority )

Background: always run tasks in a background thread, never immediately execute them. For running background jobs.

Definition at line 489 of file task_pool.cc.

References TASK_POOL_BACKGROUND.

Referenced by filelist_cache_preview_ensure_running(), blender::ed::sculpt_paint::undo::PositionUndoStorage::PositionUndoStorage(), and undomesh_from_editmesh().

◆ BLI_task_pool_create_background_serial()

TaskPool * BLI_task_pool_create_background_serial ( void * userdata,
eTaskPriority priority )

Background Serial: run tasks one after the other in the background.

Executes one task after the other, possibly on different threads but never in parallel.

Definition at line 516 of file task_pool.cc.

References TASK_POOL_BACKGROUND_SERIAL.

Referenced by screen_opengl_render_init().

◆ BLI_task_pool_create_no_threads()

TaskPool * BLI_task_pool_create_no_threads ( void * userdata)

No threads: immediately executes tasks on the same thread. For debugging purposes.

Definition at line 511 of file task_pool.cc.

References TASK_POOL_NO_THREADS, and TASK_PRIORITY_HIGH.

◆ BLI_task_pool_create_suspended()

TaskPool * BLI_task_pool_create_suspended ( void * userdata,
eTaskPriority priority )

Suspended: don't execute tasks until work_and_wait is called. This is slower as threads can't immediately start working. But it can be used if the data structures the threads operate on are not fully initialized until all tasks are created.

Definition at line 503 of file task_pool.cc.

References TASK_POOL_TBB_SUSPENDED.

Referenced by project_paint_op(), and TEST().

◆ BLI_task_pool_current_canceled()

bool BLI_task_pool_current_canceled ( TaskPool * pool)

For worker threads, test if current task pool canceled. this function may only be called from worker threads and pool must be the task pool that the thread is currently executing a task from.

Definition at line 545 of file task_pool.cc.

References TaskPool::current_canceled().

Referenced by blender::ed::vse::execute_read_sound_waveform_task(), and blender::gpu::VKDevice::submission_runner().

◆ BLI_task_pool_free()

◆ BLI_task_pool_push()

◆ BLI_task_pool_user_data()

void * BLI_task_pool_user_data ( TaskPool * pool)

◆ BLI_task_pool_work_and_wait()