forked from mirror/ants
optimization for #7
This commit is contained in:
parent
50918eb4a9
commit
e51be35d84
10
pool.go
10
pool.go
|
@ -77,12 +77,10 @@ func (p *Pool) periodicallyPurge() {
|
|||
idleWorkers[i] = nil
|
||||
}
|
||||
n++
|
||||
if n > 0 {
|
||||
if n >= len(idleWorkers) {
|
||||
p.workers = idleWorkers[:0]
|
||||
} else {
|
||||
p.workers = idleWorkers[n:]
|
||||
}
|
||||
if n >= len(idleWorkers) {
|
||||
p.workers = idleWorkers[:0]
|
||||
} else {
|
||||
p.workers = idleWorkers[n:]
|
||||
}
|
||||
p.lock.Unlock()
|
||||
}
|
||||
|
|
10
pool_func.go
10
pool_func.go
|
@ -78,12 +78,10 @@ func (p *PoolWithFunc) periodicallyPurge() {
|
|||
idleWorkers[i] = nil
|
||||
}
|
||||
n++
|
||||
if n > 0 {
|
||||
if n >= len(idleWorkers) {
|
||||
p.workers = idleWorkers[:0]
|
||||
} else {
|
||||
p.workers = idleWorkers[n:]
|
||||
}
|
||||
if n >= len(idleWorkers) {
|
||||
p.workers = idleWorkers[:0]
|
||||
} else {
|
||||
p.workers = idleWorkers[n:]
|
||||
}
|
||||
p.lock.Unlock()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue