[Jobs API]: Use worker_lock in JobTaskSource.
Possible race when Join(): - thread A: Join: worker_released_condition_->Wait() - thread C: WillRunTask: GetMaxConcurrency() returns > 0 - thread B: already running, finishes all the work GetMaxConcurrency() goes 0 - thread B: DidProcessTask: worker_released_condition_->Signal(), - thread A: Join returns (GetMaxConcurrency() is 0) - thread C: TryIncrementWorkerCountFromWorkerRelease worker count goes 1 - thread C: runs worker_task after Join To fix race when Joining, all writes to |state_| are protected by |worker_lock|. Memory ordering is no longer necessary. Alternative: cancel before Join returns with a compare and swap and loop again if new workers. Change-Id: I4e478ffae2bdaec56386739f78de089d0e74e42c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2248159 Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org> Reviewed-by:Gabriel Charette <gab@chromium.org> Cr-Commit-Position: refs/heads/master@{#781453}
Showing
This diff is collapsed.
Please register or sign in to comment