mirror of https://github.com/panjf2000/ants.git
🚀 Support not only anonymous but also explicit functions
This commit is contained in:
parent
1d33782287
commit
15507b021f
6
pool.go
6
pool.go
|
@ -28,8 +28,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type f func()
|
|
||||||
|
|
||||||
// Pool accept the tasks from client,it limits the total
|
// Pool accept the tasks from client,it limits the total
|
||||||
// of goroutines to a given number by recycling goroutines.
|
// of goroutines to a given number by recycling goroutines.
|
||||||
type Pool struct {
|
type Pool struct {
|
||||||
|
@ -123,7 +121,7 @@ func NewTimingPool(size, expiry int) (*Pool, error) {
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
// Submit submits a task to this pool.
|
// Submit submits a task to this pool.
|
||||||
func (p *Pool) Submit(task f) error {
|
func (p *Pool) Submit(task func()) error {
|
||||||
if 1 == atomic.LoadInt32(&p.release) {
|
if 1 == atomic.LoadInt32(&p.release) {
|
||||||
return ErrPoolClosed
|
return ErrPoolClosed
|
||||||
}
|
}
|
||||||
|
@ -205,7 +203,7 @@ func (p *Pool) retrieveWorker() *Worker {
|
||||||
} else {
|
} else {
|
||||||
w = &Worker{
|
w = &Worker{
|
||||||
pool: p,
|
pool: p,
|
||||||
task: make(chan f, workerChanCap),
|
task: make(chan func(), workerChanCap),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
w.run()
|
w.run()
|
||||||
|
|
Loading…
Reference in New Issue