From 88d2454bbb85fc005ae0eea4f33d3cf644554aa9 Mon Sep 17 00:00:00 2001 From: Andy Pan Date: Tue, 20 Dec 2022 22:29:21 +0800 Subject: [PATCH] fix: resolve the build failures --- pool.go | 8 +++++--- pool_func.go | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) 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()