mirror of https://github.com/panjf2000/ants.git
Merge branch 'develop'
This commit is contained in:
parent
5776f41c0d
commit
634682856f
6
pool.go
6
pool.go
|
@ -63,7 +63,6 @@ type Pool struct {
|
|||
|
||||
func (p *Pool) periodicallyPurge() {
|
||||
heartbeat := time.NewTicker(p.expiryDuration)
|
||||
go func() {
|
||||
for range heartbeat.C {
|
||||
currentTime := time.Now()
|
||||
p.lock.Lock()
|
||||
|
@ -88,7 +87,6 @@ func (p *Pool) periodicallyPurge() {
|
|||
}
|
||||
p.lock.Unlock()
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
// NewPool generates a instance of ants pool
|
||||
|
@ -110,7 +108,7 @@ func NewTimingPool(size, expiry int) (*Pool, error) {
|
|||
release: make(chan sig, 1),
|
||||
expiryDuration: time.Duration(expiry) * time.Second,
|
||||
}
|
||||
p.periodicallyPurge()
|
||||
go p.periodicallyPurge()
|
||||
return p, nil
|
||||
}
|
||||
|
||||
|
@ -208,7 +206,7 @@ func (p *Pool) getWorker() *Worker {
|
|||
} else if w == nil {
|
||||
w = &Worker{
|
||||
pool: p,
|
||||
task: make(chan f),
|
||||
task: make(chan f, 1),
|
||||
}
|
||||
w.run()
|
||||
}
|
||||
|
|
|
@ -64,7 +64,6 @@ type PoolWithFunc struct {
|
|||
|
||||
func (p *PoolWithFunc) periodicallyPurge() {
|
||||
heartbeat := time.NewTicker(p.expiryDuration)
|
||||
go func() {
|
||||
for range heartbeat.C {
|
||||
currentTime := time.Now()
|
||||
p.lock.Lock()
|
||||
|
@ -89,7 +88,6 @@ func (p *PoolWithFunc) periodicallyPurge() {
|
|||
}
|
||||
p.lock.Unlock()
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
// NewPoolWithFunc generates a instance of ants pool with a specific function
|
||||
|
@ -112,7 +110,7 @@ func NewTimingPoolWithFunc(size, expiry int, f pf) (*PoolWithFunc, error) {
|
|||
expiryDuration: time.Duration(expiry) * time.Second,
|
||||
poolFunc: f,
|
||||
}
|
||||
p.periodicallyPurge()
|
||||
go p.periodicallyPurge()
|
||||
return p, nil
|
||||
}
|
||||
|
||||
|
@ -213,7 +211,7 @@ func (p *PoolWithFunc) getWorker() *WorkerWithFunc {
|
|||
} else if w == nil {
|
||||
w = &WorkerWithFunc{
|
||||
pool: p,
|
||||
args: make(chan interface{}),
|
||||
args: make(chan interface{}, 1),
|
||||
}
|
||||
w.run()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue