Skip to content

Commit

Permalink
opt: increase the interval of waiting in ReleaseTimeout() (#325)
Browse files Browse the repository at this point in the history
  • Loading branch information
panjf2000 authored Jun 17, 2024
1 parent ee5a718 commit 0d650f5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion ants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion pool_func.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 0d650f5

Please sign in to comment.