diff --git a/pool.go b/pool.go index c7a290c..7b2bd36 100644 --- a/pool.go +++ b/pool.go @@ -286,12 +286,14 @@ func (p *Pool) Release() { // ReleaseTimeout is like Release but with a timeout, it waits all workers to exit before timing out. func (p *Pool) ReleaseTimeout(timeout time.Duration) error { - if p.IsClosed() || p.stopPurge == nil || p.stopTicktock == nil { + if p.IsClosed() || (!p.options.DisablePurge && p.stopPurge == nil) || p.stopTicktock == nil { return ErrPoolClosed } - p.stopPurge() - p.stopPurge = nil + if p.stopPurge != nil { + p.stopPurge() + p.stopPurge = nil + } p.stopTicktock() p.stopTicktock = nil p.Release() diff --git a/pool_func.go b/pool_func.go index ba54951..8c48b7d 100644 --- a/pool_func.go +++ b/pool_func.go @@ -315,12 +315,14 @@ func (p *PoolWithFunc) Release() { // ReleaseTimeout is like Release but with a timeout, it waits all workers to exit before timing out. func (p *PoolWithFunc) ReleaseTimeout(timeout time.Duration) error { - if p.IsClosed() || p.stopPurge == nil || p.stopTicktock == nil { + if p.IsClosed() || (!p.options.DisablePurge && p.stopPurge == nil) || p.stopTicktock == nil { return ErrPoolClosed } - p.stopPurge() - p.stopPurge = nil + if p.stopPurge != nil { + p.stopPurge() + p.stopPurge = nil + } p.stopTicktock() p.stopTicktock = nil p.Release()