sync: make TestPoolDequeue termination condition more robust
TestPoolDequeue creates P-1 consumer goroutines and 1 producer goroutine. Currently, if a consumer goroutine pops the last value from the dequeue, it sets a flag that stops all consumers, but the producer also periodically pops from the dequeue and doesn't set this flag. Hence, if the producer were to pop the last element, the consumers will continue to run and the test won't terminate. This CL fixes this by also setting the termination flag in the producer. I believe it's impossible for this to happen right now because the producer only pops after pushing an element for which j%10==0 and the last element is either 999 or 1999999, which means it should never try to pop after pushing the last element. However, we shouldn't depend on this reasoning. Change-Id: Icd2bc8d7cb9a79ebfcec99e367c8a2ba76e027d8 Reviewed-on: https://go-review.googlesource.com/c/go/+/183980 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
Showing
Please register or sign in to comment