diff --git a/pool.go b/pool.go index c3f5568..656bf19 100644 --- a/pool.go +++ b/pool.go @@ -78,7 +78,7 @@ func (p *Pool) periodicallyPurge() { } n++ if n > 0 { - if n >= cap(idleWorkers) { + if n >= len(idleWorkers) { p.workers = idleWorkers[:0] } else { p.workers = idleWorkers[n:] diff --git a/pool_func.go b/pool_func.go index 3e6dc5e..0b2eed5 100644 --- a/pool_func.go +++ b/pool_func.go @@ -79,7 +79,7 @@ func (p *PoolWithFunc) periodicallyPurge() { } n++ if n > 0 { - if n >= cap(idleWorkers) { + if n >= len(idleWorkers) { p.workers = idleWorkers[:0] } else { p.workers = idleWorkers[n:]