[Bf-blender-cvs] [40091ff] master: Correction to early output in the parallel range implementation
Sergey Sharybin
noreply at git.blender.org
Mon May 18 13:41:01 CEST 2015
Commit: 40091ff83aa2482db93855f53d1b4c7208a500ac
Author: Sergey Sharybin
Date: Mon May 18 12:44:59 2015 +0500
Branches: master
https://developer.blender.org/rB40091ff83aa2482db93855f53d1b4c7208a500ac
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.
===================================================================
M source/blender/blenlib/intern/task.c
===================================================================
diff --git a/source/blender/blenlib/intern/task.c b/source/blender/blenlib/intern/task.c
index f442a62..08d40a1 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;
}
More information about the Bf-blender-cvs
mailing list