forked from mirror/ants
🚀 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"
|
||||
)
|
||||
|
||||
type f func()
|
||||
|
||||
// Pool accept the tasks from client,it limits the total
|
||||
// of goroutines to a given number by recycling goroutines.
|
||||
type Pool struct {
|
||||
|
@ -123,7 +121,7 @@ func NewTimingPool(size, expiry int) (*Pool, error) {
|
|||
//---------------------------------------------------------------------------
|
||||
|
||||
// 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) {
|
||||
return ErrPoolClosed
|
||||
}
|
||||
|
@ -205,7 +203,7 @@ func (p *Pool) retrieveWorker() *Worker {
|
|||
} else {
|
||||
w = &Worker{
|
||||
pool: p,
|
||||
task: make(chan f, workerChanCap),
|
||||
task: make(chan func(), workerChanCap),
|
||||
}
|
||||
}
|
||||
w.run()
|
||||
|
|
Loading…
Reference in New Issue