forked from mirror/ants
A little bit of optimization in periodicallyPurge()
This commit is contained in:
parent
cbf8ddf048
commit
44aec9954f
5
pool.go
5
pool.go
|
@ -89,9 +89,8 @@ func (p *Pool) periodicallyPurge() {
|
|||
p.lock.Lock()
|
||||
idleWorkers := p.workers
|
||||
n := len(idleWorkers)
|
||||
i := 0
|
||||
for i < n && currentTime.Sub(idleWorkers[i].recycleTime) > p.expiryDuration {
|
||||
i++
|
||||
var i int
|
||||
for i = 0; i < n && currentTime.Sub(idleWorkers[i].recycleTime) > p.expiryDuration; i++ {
|
||||
}
|
||||
expiredWorkers = append(expiredWorkers[:0], idleWorkers[:i]...)
|
||||
if i > 0 {
|
||||
|
|
|
@ -92,9 +92,8 @@ func (p *PoolWithFunc) periodicallyPurge() {
|
|||
p.lock.Lock()
|
||||
idleWorkers := p.workers
|
||||
n := len(idleWorkers)
|
||||
i := 0
|
||||
for i < n && currentTime.Sub(idleWorkers[i].recycleTime) > p.expiryDuration {
|
||||
i++
|
||||
var i int
|
||||
for i = 0; i < n && currentTime.Sub(idleWorkers[i].recycleTime) > p.expiryDuration; i++ {
|
||||
}
|
||||
expiredWorkers = append(expiredWorkers[:0], idleWorkers[:i]...)
|
||||
if i > 0 {
|
||||
|
|
Loading…
Reference in New Issue