mirror of https://github.com/panjf2000/ants.git
🙄 Improvement in `periodicallyPurge`
This commit is contained in:
parent
00294fd50b
commit
d6076c09aa
7
pool.go
7
pool.go
|
@ -69,13 +69,12 @@ func (p *Pool) periodicallyPurge() {
|
|||
defer heartbeat.Stop()
|
||||
|
||||
for range heartbeat.C {
|
||||
if CLOSED == atomic.LoadInt32(&p.release) {
|
||||
break
|
||||
}
|
||||
currentTime := time.Now()
|
||||
p.lock.Lock()
|
||||
idleWorkers := p.workers
|
||||
if CLOSED == atomic.LoadInt32(&p.release) {
|
||||
p.lock.Unlock()
|
||||
return
|
||||
}
|
||||
n := -1
|
||||
for i, w := range idleWorkers {
|
||||
if currentTime.Sub(w.recycleTime) <= p.expiryDuration {
|
||||
|
|
|
@ -72,13 +72,12 @@ func (p *PoolWithFunc) periodicallyPurge() {
|
|||
defer heartbeat.Stop()
|
||||
|
||||
for range heartbeat.C {
|
||||
if CLOSED == atomic.LoadInt32(&p.release) {
|
||||
break
|
||||
}
|
||||
currentTime := time.Now()
|
||||
p.lock.Lock()
|
||||
idleWorkers := p.workers
|
||||
if CLOSED == atomic.LoadInt32(&p.release) {
|
||||
p.lock.Unlock()
|
||||
return
|
||||
}
|
||||
n := -1
|
||||
for i, w := range idleWorkers {
|
||||
if currentTime.Sub(w.recycleTime) <= p.expiryDuration {
|
||||
|
|
Loading…
Reference in New Issue