diff --git a/pool.go b/pool.go index 41fd61d..c7a290c 100644 --- a/pool.go +++ b/pool.go @@ -137,12 +137,14 @@ func (p *Pool) ticktock(ctx context.Context) { } func (p *Pool) goPurge() { + if p.options.DisablePurge { + return + } + // Start a goroutine to clean up expired workers periodically. var ctx context.Context ctx, p.stopPurge = context.WithCancel(context.Background()) - if !p.options.DisablePurge { - go p.purgeStaleWorkers(ctx) - } + go p.purgeStaleWorkers(ctx) } func (p *Pool) goTicktock() { diff --git a/pool_func.go b/pool_func.go index ec2dfd2..ba54951 100644 --- a/pool_func.go +++ b/pool_func.go @@ -160,12 +160,14 @@ func (p *PoolWithFunc) ticktock(ctx context.Context) { } func (p *PoolWithFunc) goPurge() { + if p.options.DisablePurge { + return + } + // Start a goroutine to clean up expired workers periodically. var ctx context.Context ctx, p.stopPurge = context.WithCancel(context.Background()) - if !p.options.DisablePurge { - go p.purgeStaleWorkers(ctx) - } + go p.purgeStaleWorkers(ctx) } func (p *PoolWithFunc) goTicktock() {