mirror of https://github.com/panjf2000/ants.git
bug: alleviate the data race between Release() and Reboot() (#333)
This commit is contained in:
parent
da22980e2c
commit
b40e489286
3
pool.go
3
pool.go
|
@ -135,9 +135,10 @@ func (p *Pool) ticktock() {
|
|||
atomic.StoreInt32(&p.ticktockDone, 1)
|
||||
}()
|
||||
|
||||
ticktockCtx := p.ticktockCtx // copy to the local variable to avoid race from Reboot()
|
||||
for {
|
||||
select {
|
||||
case <-p.ticktockCtx.Done():
|
||||
case <-ticktockCtx.Done():
|
||||
return
|
||||
case <-ticker.C:
|
||||
}
|
||||
|
|
|
@ -92,9 +92,10 @@ func (p *PoolWithFunc) ticktock() {
|
|||
atomic.StoreInt32(&p.ticktockDone, 1)
|
||||
}()
|
||||
|
||||
ticktockCtx := p.ticktockCtx // copy to the local variable to avoid race from Reboot()
|
||||
for {
|
||||
select {
|
||||
case <-p.ticktockCtx.Done():
|
||||
case <-ticktockCtx.Done():
|
||||
return
|
||||
case <-ticker.C:
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue