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:
authorSergey Sharybin <sergey.vfx@gmail.com>2018-01-22 14:56:35 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2018-01-22 14:56:35 +0300
commitaf83535dd0f2032c72abd62254f566da2db9f65b (patch)
tree9110cf1fbaadafd8127885cd1ff75ddac2f8c7b5
parenta3616980c6e6491faa726090a47c89b1ab2119a4 (diff)
Task scheduler: Clarify why do we need an atomic add of 0
-rw-r--r--source/blender/blenlib/intern/task.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/task.c b/source/blender/blenlib/intern/task.c
index e050f3148b8..da632e92e08 100644
--- a/source/blender/blenlib/intern/task.c
+++ b/source/blender/blenlib/intern/task.c
@@ -1124,6 +1124,9 @@ static void task_parallel_range_ex(
}
num_tasks = min_ii(num_tasks, (stop - start) / state.chunk_size);
+
+ /* NOTE: This way we are adding a memory barrier and ensure all worker
+ * threads can read and modify the value, without any locks. */
atomic_fetch_and_add_uint32((uint32_t *)(&state.iter), 0);
if (use_userdata_chunk) {