mirror of https://github.com/panjf2000/ants.git
optimization for cleaning workers
This commit is contained in:
parent
f667e2f78a
commit
e25a58c9f3
2
pool.go
2
pool.go
|
@ -77,7 +77,7 @@ func (p *Pool) periodicallyPurge() {
|
||||||
idleWorkers[i] = nil
|
idleWorkers[i] = nil
|
||||||
}
|
}
|
||||||
if n > -1 {
|
if n > -1 {
|
||||||
if n >= len(idleWorkers) {
|
if n >= len(idleWorkers)-1 {
|
||||||
p.workers = idleWorkers[:0]
|
p.workers = idleWorkers[:0]
|
||||||
} else {
|
} else {
|
||||||
p.workers = idleWorkers[n+1:]
|
p.workers = idleWorkers[n+1:]
|
||||||
|
|
|
@ -78,7 +78,7 @@ func (p *PoolWithFunc) periodicallyPurge() {
|
||||||
idleWorkers[i] = nil
|
idleWorkers[i] = nil
|
||||||
}
|
}
|
||||||
if n > -1 {
|
if n > -1 {
|
||||||
if n >= len(idleWorkers) {
|
if n >= len(idleWorkers)-1 {
|
||||||
p.workers = idleWorkers[:0]
|
p.workers = idleWorkers[:0]
|
||||||
} else {
|
} else {
|
||||||
p.workers = idleWorkers[n+1:]
|
p.workers = idleWorkers[n+1:]
|
||||||
|
|
Loading…
Reference in New Issue