Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenlib/BLI_task.h
| Show First 20 Lines • Show All 192 Lines • ▼ Show 20 Lines | |||||
| BLI_INLINE void BLI_parallel_range_settings_defaults(TaskParallelSettings *settings); | BLI_INLINE void BLI_parallel_range_settings_defaults(TaskParallelSettings *settings); | ||||
| void BLI_task_parallel_range(const int start, | void BLI_task_parallel_range(const int start, | ||||
| const int stop, | const int stop, | ||||
| void *userdata, | void *userdata, | ||||
| TaskParallelRangeFunc func, | TaskParallelRangeFunc func, | ||||
| const TaskParallelSettings *settings); | const TaskParallelSettings *settings); | ||||
| typedef void (*TaskParallelListbaseFunc)(void *userdata, struct Link *iter, int index); | /* This data is shared between all tasks, its access needs thread lock or similar protection. */ | ||||
| typedef struct TaskParallelIteratorStateShared { | |||||
| /* Maximum amount of items to acquire at once. */ | |||||
| int chunk_size; | |||||
| /* Next item to be acquired. */ | |||||
| void *next_item; | |||||
| /* Index of the next item to be acquired. */ | |||||
| int next_index; | |||||
| /* Helper lock to protect access to this data in iterator getter callback, | |||||
sergey: That or this data? | |||||
Done Inline ActionsEeeeeh... Does it matter at all here? mont29: Eeeeeh... Does it matter at all here? | |||||
| * can be ignored (if the callback implements its own protection system, using atomics e.g.). | |||||
| * Will be NULL when iterator is actually processed in a single thread. */ | |||||
| SpinLock *spin_lock; | |||||
| } TaskParallelIteratorStateShared; | |||||
| /* This data is local (owned) by each thread, its access does not need to be protected. */ | |||||
Done Inline ActionsTask or thread? sergey: Task or thread? | |||||
| typedef struct TaskParallelIteratorStateTLS { | |||||
| /* Array of pointers to the currently acquired items. */ | |||||
| void **current_chunk_items; | |||||
| /* Array of indices of the currently acquired items. */ | |||||
| int *current_chunk_indices; | |||||
| /* Number of items in the two arrays, i.e. number of items effectively acquired, | |||||
| * always <= TaskParallelIteratorStateShared.chunk_size. */ | |||||
| int current_chunk_size; | |||||
| } TaskParallelIteratorStateTLS; | |||||
| typedef void (*TaskParallelIteratorIterFunc)( | |||||
| void *__restrict userdata, | |||||
| const TaskParallelTLS *__restrict tls, | |||||
| TaskParallelIteratorStateShared *__restrict state_shared, | |||||
| TaskParallelIteratorStateTLS *__restrict state_tls); | |||||
| typedef void (*TaskParallelIteratorFunc)(void *__restrict userdata, | |||||
| void *item, | |||||
| int index, | |||||
| const TaskParallelTLS *__restrict tls); | |||||
| void BLI_task_parallel_iterator(void *userdata, | |||||
| TaskParallelIteratorIterFunc iter_func, | |||||
| void *init_item, | |||||
| const int init_index, | |||||
| const int tot_items, | |||||
| TaskParallelIteratorFunc func, | |||||
| const TaskParallelSettings *settings); | |||||
| void BLI_task_parallel_listbase(struct ListBase *listbase, | void BLI_task_parallel_listbase(struct ListBase *listbase, | ||||
| void *userdata, | void *userdata, | ||||
| TaskParallelListbaseFunc func, | TaskParallelIteratorFunc func, | ||||
| const bool use_threading); | const TaskParallelSettings *settings); | ||||
| typedef struct MempoolIterData MempoolIterData; | typedef struct MempoolIterData MempoolIterData; | ||||
| typedef void (*TaskParallelMempoolFunc)(void *userdata, MempoolIterData *iter); | typedef void (*TaskParallelMempoolFunc)(void *userdata, MempoolIterData *iter); | ||||
| void BLI_task_parallel_mempool(struct BLI_mempool *mempool, | void BLI_task_parallel_mempool(struct BLI_mempool *mempool, | ||||
| void *userdata, | void *userdata, | ||||
| TaskParallelMempoolFunc func, | TaskParallelMempoolFunc func, | ||||
| const bool use_threading); | const bool use_threading); | ||||
| Show All 15 Lines | |||||
That or this data?