diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-01-22 14:56:35 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-01-22 14:56:35 +0300 |
commit | af83535dd0f2032c72abd62254f566da2db9f65b (patch) | |
tree | 9110cf1fbaadafd8127885cd1ff75ddac2f8c7b5 | |
parent | a3616980c6e6491faa726090a47c89b1ab2119a4 (diff) |
Task scheduler: Clarify why do we need an atomic add of 0
-rw-r--r-- | source/blender/blenlib/intern/task.c | 3 |
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) { |