opt: increase the interval of waiting in ReleaseTimeout() (#325)

This commit is contained in:
Andy Pan 2024-06-17 18:21:01 +08:00 committed by GitHub
parent ee5a7183d9
commit 0d650f5c1e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 3 deletions

View File

@ -96,7 +96,10 @@ var (
defaultAntsPool, _ = NewPool(DefaultAntsPoolSize)
)
const nowTimeUpdateInterval = 500 * time.Millisecond
const (
nowTimeUpdateInterval = 500 * time.Millisecond
releaseTimeoutInterval = 100 * time.Millisecond
)
// Logger is used for logging formatted messages.
type Logger interface {

View File

@ -306,7 +306,7 @@ func (p *Pool) ReleaseTimeout(timeout time.Duration) error {
atomic.LoadInt32(&p.ticktockDone) == 1 {
return nil
}
time.Sleep(10 * time.Millisecond)
time.Sleep(releaseTimeoutInterval)
}
return ErrTimeout
}

View File

@ -311,7 +311,7 @@ func (p *PoolWithFunc) ReleaseTimeout(timeout time.Duration) error {
atomic.LoadInt32(&p.ticktockDone) == 1 {
return nil
}
time.Sleep(10 * time.Millisecond)
time.Sleep(releaseTimeoutInterval)
}
return ErrTimeout
}