diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-05-18 10:44:59 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-05-18 14:40:51 +0300 |
commit | 40091ff83aa2482db93855f53d1b4c7208a500ac (patch) | |
tree | 8fa5bd27039898752b3fcc69b2a29700418f1081 /source/blender | |
parent | b88597c2186689e8eaaf3cb3f5b2601b449781fe (diff) |
Correction to early output in the parallel range implementation
The used heuristic of checking the value prior to lock is not totally safe
because assignment is not atomic and check might not give proper result.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenlib/intern/task.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/source/blender/blenlib/intern/task.c b/source/blender/blenlib/intern/task.c index f442a6219a5..08d40a158ca 100644 --- a/source/blender/blenlib/intern/task.c +++ b/source/blender/blenlib/intern/task.c @@ -508,16 +508,14 @@ BLI_INLINE bool parallel_range_next_iter_get( int * __restrict iter, int * __restrict count) { bool result = false; + BLI_spin_lock(&state->lock); if (state->iter < state->stop) { - BLI_spin_lock(&state->lock); - if (state->iter < state->stop) { - *count = min_ii(state->chunk_size, state->stop - state->iter); - *iter = state->iter; - state->iter += *count; - result = true; - } - BLI_spin_unlock(&state->lock); + *count = min_ii(state->chunk_size, state->stop - state->iter); + *iter = state->iter; + state->iter += *count; + result = true; } + BLI_spin_unlock(&state->lock); return result; } |