diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-12-22 18:37:25 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-12-22 18:37:25 +0300 |
commit | 6efd58dd3e2a6be696b00d68ad775d75def79b26 (patch) | |
tree | 421a86e67afdf4ae0682687645bcbb3ebf77f76b /source/blender/blenlib/intern/task.c | |
parent | 870840e8b7dd8860691de0910ade3f0d0f217f14 (diff) |
Task scheduler: Clarify why do we need an atomic add of 0
Diffstat (limited to 'source/blender/blenlib/intern/task.c')
-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 311be1dd151..afa20e3d766 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_int32(&state.iter, 0); if (use_userdata_chunk) { |