Merge pull request #288 from panjf2000/dev

ver: release v2.8.1
This commit is contained in:
Andy Pan 2023-07-06 19:15:33 +08:00 committed by GitHub
commit 128b4b5893
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 14 deletions

15
pool.go
View File

@ -276,6 +276,14 @@ func (p *Pool) Release() {
if !atomic.CompareAndSwapInt32(&p.state, OPENED, CLOSED) { if !atomic.CompareAndSwapInt32(&p.state, OPENED, CLOSED) {
return return
} }
if p.stopPurge != nil {
p.stopPurge()
p.stopPurge = nil
}
p.stopTicktock()
p.stopTicktock = nil
p.lock.Lock() p.lock.Lock()
p.workers.reset() p.workers.reset()
p.lock.Unlock() p.lock.Unlock()
@ -289,13 +297,6 @@ func (p *Pool) ReleaseTimeout(timeout time.Duration) error {
if p.IsClosed() || (!p.options.DisablePurge && p.stopPurge == nil) || p.stopTicktock == nil { if p.IsClosed() || (!p.options.DisablePurge && p.stopPurge == nil) || p.stopTicktock == nil {
return ErrPoolClosed return ErrPoolClosed
} }
if p.stopPurge != nil {
p.stopPurge()
p.stopPurge = nil
}
p.stopTicktock()
p.stopTicktock = nil
p.Release() p.Release()
endTime := time.Now().Add(timeout) endTime := time.Now().Add(timeout)

View File

@ -282,6 +282,14 @@ func (p *PoolWithFunc) Release() {
if !atomic.CompareAndSwapInt32(&p.state, OPENED, CLOSED) { if !atomic.CompareAndSwapInt32(&p.state, OPENED, CLOSED) {
return return
} }
if p.stopPurge != nil {
p.stopPurge()
p.stopPurge = nil
}
p.stopTicktock()
p.stopTicktock = nil
p.lock.Lock() p.lock.Lock()
p.workers.reset() p.workers.reset()
p.lock.Unlock() p.lock.Unlock()
@ -295,13 +303,6 @@ func (p *PoolWithFunc) ReleaseTimeout(timeout time.Duration) error {
if p.IsClosed() || (!p.options.DisablePurge && p.stopPurge == nil) || p.stopTicktock == nil { if p.IsClosed() || (!p.options.DisablePurge && p.stopPurge == nil) || p.stopTicktock == nil {
return ErrPoolClosed return ErrPoolClosed
} }
if p.stopPurge != nil {
p.stopPurge()
p.stopPurge = nil
}
p.stopTicktock()
p.stopTicktock = nil
p.Release() p.Release()
endTime := time.Now().Add(timeout) endTime := time.Now().Add(timeout)