mirror of https://github.com/panjf2000/ants.git
Merge branch 'develop'
This commit is contained in:
commit
666635c65d
10
pool.go
10
pool.go
|
@ -77,12 +77,10 @@ func (p *Pool) periodicallyPurge() {
|
||||||
idleWorkers[i] = nil
|
idleWorkers[i] = nil
|
||||||
}
|
}
|
||||||
n++
|
n++
|
||||||
if n > 0 {
|
if n >= len(idleWorkers) {
|
||||||
if n >= len(idleWorkers) {
|
p.workers = idleWorkers[:0]
|
||||||
p.workers = idleWorkers[:0]
|
} else {
|
||||||
} else {
|
p.workers = idleWorkers[n:]
|
||||||
p.workers = idleWorkers[n:]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
p.lock.Unlock()
|
p.lock.Unlock()
|
||||||
}
|
}
|
||||||
|
|
10
pool_func.go
10
pool_func.go
|
@ -78,12 +78,10 @@ func (p *PoolWithFunc) periodicallyPurge() {
|
||||||
idleWorkers[i] = nil
|
idleWorkers[i] = nil
|
||||||
}
|
}
|
||||||
n++
|
n++
|
||||||
if n > 0 {
|
if n >= len(idleWorkers) {
|
||||||
if n >= len(idleWorkers) {
|
p.workers = idleWorkers[:0]
|
||||||
p.workers = idleWorkers[:0]
|
} else {
|
||||||
} else {
|
p.workers = idleWorkers[n:]
|
||||||
p.workers = idleWorkers[n:]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
p.lock.Unlock()
|
p.lock.Unlock()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue