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 } }