diff --git a/pool.go b/pool.go index 7a7a48e..987ba4d 100644 --- a/pool.go +++ b/pool.go @@ -77,7 +77,7 @@ func (p *Pool) periodicallyPurge() { idleWorkers[i] = nil } if n > -1 { - if n >= len(idleWorkers) { + if n >= len(idleWorkers)-1 { p.workers = idleWorkers[:0] } else { p.workers = idleWorkers[n+1:] diff --git a/pool_func.go b/pool_func.go index 7c0df59..6051117 100644 --- a/pool_func.go +++ b/pool_func.go @@ -78,7 +78,7 @@ func (p *PoolWithFunc) periodicallyPurge() { idleWorkers[i] = nil } if n > -1 { - if n >= len(idleWorkers) { + if n >= len(idleWorkers)-1 { p.workers = idleWorkers[:0] } else { p.workers = idleWorkers[n+1:]