Merge branch 'develop'

This commit is contained in:
Andy Pan 2018-08-08 21:44:44 +08:00
commit 666635c65d
2 changed files with 8 additions and 12 deletions

10
pool.go
View File

@ -77,12 +77,10 @@ func (p *Pool) periodicallyPurge() {
idleWorkers[i] = nil
}
n++
if n > 0 {
if n >= len(idleWorkers) {
p.workers = idleWorkers[:0]
} else {
p.workers = idleWorkers[n:]
}
if n >= len(idleWorkers) {
p.workers = idleWorkers[:0]
} else {
p.workers = idleWorkers[n:]
}
p.lock.Unlock()
}

View File

@ -78,12 +78,10 @@ func (p *PoolWithFunc) periodicallyPurge() {
idleWorkers[i] = nil
}
n++
if n > 0 {
if n >= len(idleWorkers) {
p.workers = idleWorkers[:0]
} else {
p.workers = idleWorkers[n:]
}
if n >= len(idleWorkers) {
p.workers = idleWorkers[:0]
} else {
p.workers = idleWorkers[n:]
}
p.lock.Unlock()
}