From 9648c3ec6633997f2ee46cc957bff4ab92323ee0 Mon Sep 17 00:00:00 2001 From: alitto Date: Tue, 31 Mar 2020 11:39:15 -0300 Subject: [PATCH] Prevent data race in purger --- pond.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pond.go b/pond.go index a2f2e9e..b4c9ac1 100644 --- a/pond.go +++ b/pond.go @@ -243,9 +243,6 @@ func (p *WorkerPool) dispatch() { batch = nil } - // Send signal to stop all workers - close(p.dispatchedTasks) - // Send signal to stop the purger close(p.purgerQuit) } @@ -269,6 +266,10 @@ func (p *WorkerPool) purge() { // Received the signal to exit case <-p.purgerQuit: + + // Send signal to stop all workers + close(p.dispatchedTasks) + return } }