diff --git a/pool.go b/pool.go index 4e93a36..5a13182 100644 --- a/pool.go +++ b/pool.go @@ -75,8 +75,8 @@ func (p *Pool) periodicallyPurge() { w.task <- nil idleWorkers[i] = nil } + n++ if n > 0 { - n++ p.workers = idleWorkers[n:] } p.lock.Unlock() diff --git a/pool_func.go b/pool_func.go index 944a6ba..ee23b9e 100644 --- a/pool_func.go +++ b/pool_func.go @@ -77,8 +77,8 @@ func (p *PoolWithFunc) periodicallyPurge() { w.args <- nil idleWorkers[i] = nil } + n++ if n > 0 { - n++ p.workers = idleWorkers[n:] } p.lock.Unlock()