Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2016-05-16 18:15:18 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2016-05-16 18:15:18 +0300
commit688858d3a807536d2bdcead7b50fc4d0496dab44 (patch)
tree8304480488491a0f3cef72e731da32a7ad9ceac0 /source/blender/blenlib/BLI_task.h
parent5a7429c36302b872b8de2eaec88984a9b98cc613 (diff)
BLI_task: Add new 'BLI_task_parallel_range_finalize()'.
Together with the extended loop callback and userdata_chunk, this allows to perform cumulative tasks (like aggregation) in a lockfree way using local userdata_chunk to store temp data, and once all workers have finished, to merge those userdata_chunks in the finalize callback (from calling thread, so no need to lock here either). Note that this changes how userdata_chunk is handled (now fully from 'main' thread, which means a given worker thread will always get the same userdata_chunk, without being re-initialized anymore to init value at start of each iter chunk).
Diffstat (limited to 'source/blender/blenlib/BLI_task.h')
-rw-r--r--source/blender/blenlib/BLI_task.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/source/blender/blenlib/BLI_task.h b/source/blender/blenlib/BLI_task.h
index c511ec432ee..967e0be6d0a 100644
--- a/source/blender/blenlib/BLI_task.h
+++ b/source/blender/blenlib/BLI_task.h
@@ -119,11 +119,13 @@ size_t BLI_task_pool_tasks_done(TaskPool *pool);
/* Parallel for routines */
typedef void (*TaskParallelRangeFunc)(void *userdata, const int iter);
typedef void (*TaskParallelRangeFuncEx)(void *userdata, void *userdata_chunk, const int iter, const int thread_id);
+typedef void (*TaskParallelRangeFuncFinalize)(void *userdata, void *userdata_chunk);
void BLI_task_parallel_range_ex(
int start, int stop,
void *userdata,
void *userdata_chunk,
- const size_t userdata_chunk_size, TaskParallelRangeFuncEx func_ex,
+ const size_t userdata_chunk_size,
+ TaskParallelRangeFuncEx func_ex,
const bool use_threading,
const bool use_dynamic_scheduling);
void BLI_task_parallel_range(
@@ -132,6 +134,16 @@ void BLI_task_parallel_range(
TaskParallelRangeFunc func,
const bool use_threading);
+void BLI_task_parallel_range_finalize(
+ int start, int stop,
+ void *userdata,
+ void *userdata_chunk,
+ const size_t userdata_chunk_size,
+ TaskParallelRangeFuncEx func_ex,
+ TaskParallelRangeFuncFinalize func_finalize,
+ const bool use_threading,
+ const bool use_dynamic_scheduling);
+
typedef void (*TaskParallelListbaseFunc)(void *userdata,
struct Link *iter,
int index);