mirror of
https://github.com/panjf2000/ants.git
synced 2025-12-16 09:51:02 +00:00
opt: increase the interval of waiting in ReleaseTimeout() (#325)
This commit is contained in:
parent
ee5a7183d9
commit
0d650f5c1e
5
ants.go
5
ants.go
@ -96,7 +96,10 @@ var (
|
|||||||
defaultAntsPool, _ = NewPool(DefaultAntsPoolSize)
|
defaultAntsPool, _ = NewPool(DefaultAntsPoolSize)
|
||||||
)
|
)
|
||||||
|
|
||||||
const nowTimeUpdateInterval = 500 * time.Millisecond
|
const (
|
||||||
|
nowTimeUpdateInterval = 500 * time.Millisecond
|
||||||
|
releaseTimeoutInterval = 100 * time.Millisecond
|
||||||
|
)
|
||||||
|
|
||||||
// Logger is used for logging formatted messages.
|
// Logger is used for logging formatted messages.
|
||||||
type Logger interface {
|
type Logger interface {
|
||||||
|
|||||||
2
pool.go
2
pool.go
@ -306,7 +306,7 @@ func (p *Pool) ReleaseTimeout(timeout time.Duration) error {
|
|||||||
atomic.LoadInt32(&p.ticktockDone) == 1 {
|
atomic.LoadInt32(&p.ticktockDone) == 1 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
time.Sleep(10 * time.Millisecond)
|
time.Sleep(releaseTimeoutInterval)
|
||||||
}
|
}
|
||||||
return ErrTimeout
|
return ErrTimeout
|
||||||
}
|
}
|
||||||
|
|||||||
@ -311,7 +311,7 @@ func (p *PoolWithFunc) ReleaseTimeout(timeout time.Duration) error {
|
|||||||
atomic.LoadInt32(&p.ticktockDone) == 1 {
|
atomic.LoadInt32(&p.ticktockDone) == 1 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
time.Sleep(10 * time.Millisecond)
|
time.Sleep(releaseTimeoutInterval)
|
||||||
}
|
}
|
||||||
return ErrTimeout
|
return ErrTimeout
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user