mirror of https://github.com/panjf2000/ants.git
Merge branch 'develop'
This commit is contained in:
commit
7fb8ca409b
4
pool.go
4
pool.go
|
@ -61,7 +61,7 @@ type Pool struct {
|
||||||
once sync.Once
|
once sync.Once
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Pool) monitorAndClear() {
|
func (p *Pool) periodicallyPurge() {
|
||||||
heartbeat := time.NewTicker(p.expiryDuration)
|
heartbeat := time.NewTicker(p.expiryDuration)
|
||||||
go func() {
|
go func() {
|
||||||
for range heartbeat.C {
|
for range heartbeat.C {
|
||||||
|
@ -110,7 +110,7 @@ func NewTimingPool(size, expiry int) (*Pool, error) {
|
||||||
release: make(chan sig, 1),
|
release: make(chan sig, 1),
|
||||||
expiryDuration: time.Duration(expiry) * time.Second,
|
expiryDuration: time.Duration(expiry) * time.Second,
|
||||||
}
|
}
|
||||||
p.monitorAndClear()
|
p.periodicallyPurge()
|
||||||
return p, nil
|
return p, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ type PoolWithFunc struct {
|
||||||
once sync.Once
|
once sync.Once
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PoolWithFunc) monitorAndClear() {
|
func (p *PoolWithFunc) periodicallyPurge() {
|
||||||
heartbeat := time.NewTicker(p.expiryDuration)
|
heartbeat := time.NewTicker(p.expiryDuration)
|
||||||
go func() {
|
go func() {
|
||||||
for range heartbeat.C {
|
for range heartbeat.C {
|
||||||
|
@ -112,7 +112,7 @@ func NewTimingPoolWithFunc(size, expiry int, f pf) (*PoolWithFunc, error) {
|
||||||
expiryDuration: time.Duration(expiry) * time.Second,
|
expiryDuration: time.Duration(expiry) * time.Second,
|
||||||
poolFunc: f,
|
poolFunc: f,
|
||||||
}
|
}
|
||||||
p.monitorAndClear()
|
p.periodicallyPurge()
|
||||||
return p, nil
|
return p, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue