forked from mirror/ants
fixed #7 清理过期协程报错
This commit is contained in:
commit
1b77c3ece5
2
pool.go
2
pool.go
|
@ -78,7 +78,7 @@ func (p *Pool) periodicallyPurge() {
|
||||||
}
|
}
|
||||||
n++
|
n++
|
||||||
if n > 0 {
|
if n > 0 {
|
||||||
if n >= cap(idleWorkers) {
|
if n >= len(idleWorkers) {
|
||||||
p.workers = idleWorkers[:0]
|
p.workers = idleWorkers[:0]
|
||||||
} else {
|
} else {
|
||||||
p.workers = idleWorkers[n:]
|
p.workers = idleWorkers[n:]
|
||||||
|
|
|
@ -79,7 +79,7 @@ func (p *PoolWithFunc) periodicallyPurge() {
|
||||||
}
|
}
|
||||||
n++
|
n++
|
||||||
if n > 0 {
|
if n > 0 {
|
||||||
if n >= cap(idleWorkers) {
|
if n >= len(idleWorkers) {
|
||||||
p.workers = idleWorkers[:0]
|
p.workers = idleWorkers[:0]
|
||||||
} else {
|
} else {
|
||||||
p.workers = idleWorkers[n:]
|
p.workers = idleWorkers[n:]
|
||||||
|
|
Loading…
Reference in New Issue