optimization for cleaning workers

This commit is contained in:
andy pan 2018-08-29 10:02:41 +08:00
parent f667e2f78a
commit e25a58c9f3
2 changed files with 2 additions and 2 deletions

View File

@ -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:]

View File

@ -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:]