forked from bartvdbraak/blender
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.
This commit is contained in:
parent
b88597c218
commit
40091ff83a
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user