mirror of https://github.com/panjf2000/ants.git
update
This commit is contained in:
parent
3a8cc09373
commit
a59f51fefd
4
ants.go
4
ants.go
|
@ -1,8 +1,6 @@
|
|||
package ants
|
||||
|
||||
import "math"
|
||||
|
||||
const DEFAULT_POOL_SIZE = math.MaxInt32
|
||||
const DEFAULT_POOL_SIZE = 10000
|
||||
|
||||
var defaultPool = NewPool(DEFAULT_POOL_SIZE)
|
||||
|
||||
|
|
4
pool.go
4
pool.go
|
@ -105,18 +105,18 @@ func (p *Pool) newWorker() *Worker {
|
|||
exit: make(chan sig),
|
||||
}
|
||||
worker.run()
|
||||
atomic.AddInt32(&p.running, 1)
|
||||
return worker
|
||||
}
|
||||
|
||||
func (p *Pool) getWorker() *Worker {
|
||||
defer atomic.AddInt32(&p.running, 1)
|
||||
if w := p.workers.pop(); w != nil {
|
||||
return w.(*Worker)
|
||||
}
|
||||
return p.newWorker()
|
||||
}
|
||||
|
||||
func (p *Pool) PutWorker(worker *Worker) {
|
||||
func (p *Pool) putWorker(worker *Worker) {
|
||||
p.workers.push(worker)
|
||||
if p.reachLimit() {
|
||||
p.freeSignal <- sig{}
|
||||
|
|
Loading…
Reference in New Issue