forked from mirror/ants
opt: refine some code
This commit is contained in:
parent
858f91f48b
commit
b6eaea118b
6
pool.go
6
pool.go
|
@ -137,12 +137,14 @@ func (p *Pool) ticktock(ctx context.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Pool) goPurge() {
|
func (p *Pool) goPurge() {
|
||||||
|
if p.options.DisablePurge {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Start a goroutine to clean up expired workers periodically.
|
// Start a goroutine to clean up expired workers periodically.
|
||||||
var ctx context.Context
|
var ctx context.Context
|
||||||
ctx, p.stopPurge = context.WithCancel(context.Background())
|
ctx, p.stopPurge = context.WithCancel(context.Background())
|
||||||
if !p.options.DisablePurge {
|
|
||||||
go p.purgeStaleWorkers(ctx)
|
go p.purgeStaleWorkers(ctx)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Pool) goTicktock() {
|
func (p *Pool) goTicktock() {
|
||||||
|
|
|
@ -160,12 +160,14 @@ func (p *PoolWithFunc) ticktock(ctx context.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PoolWithFunc) goPurge() {
|
func (p *PoolWithFunc) goPurge() {
|
||||||
|
if p.options.DisablePurge {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Start a goroutine to clean up expired workers periodically.
|
// Start a goroutine to clean up expired workers periodically.
|
||||||
var ctx context.Context
|
var ctx context.Context
|
||||||
ctx, p.stopPurge = context.WithCancel(context.Background())
|
ctx, p.stopPurge = context.WithCancel(context.Background())
|
||||||
if !p.options.DisablePurge {
|
|
||||||
go p.purgeStaleWorkers(ctx)
|
go p.purgeStaleWorkers(ctx)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PoolWithFunc) goTicktock() {
|
func (p *PoolWithFunc) goTicktock() {
|
||||||
|
|
Loading…
Reference in New Issue