fixed 清理过期协程报错

This commit is contained in:
andy pan 2018-08-08 18:58:01 +08:00
commit 1b77c3ece5
2 changed files with 2 additions and 2 deletions

View File

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

View File

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