mirror of https://github.com/panjf2000/ants.git
make some methods unexported
This commit is contained in:
parent
da5b1bba5c
commit
042109890a
10
pool.go
10
pool.go
|
@ -129,13 +129,13 @@ func (p *Pool) Running() int {
|
||||||
return int(atomic.LoadInt32(&p.running))
|
return int(atomic.LoadInt32(&p.running))
|
||||||
}
|
}
|
||||||
|
|
||||||
// IncrRunning increases the number of the currently running goroutines
|
// incrRunning increases the number of the currently running goroutines
|
||||||
func (p *Pool) IncrRunning() {
|
func (p *Pool) incrRunning() {
|
||||||
atomic.AddInt32(&p.running, 1)
|
atomic.AddInt32(&p.running, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DecrRunning decreases the number of the currently running goroutines
|
// decrRunning decreases the number of the currently running goroutines
|
||||||
func (p *Pool) DecrRunning() {
|
func (p *Pool) decrRunning() {
|
||||||
atomic.AddInt32(&p.running, -1)
|
atomic.AddInt32(&p.running, -1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ func (p *Pool) getWorker() *Worker {
|
||||||
task: make(chan f, 1),
|
task: make(chan f, 1),
|
||||||
}
|
}
|
||||||
w.run()
|
w.run()
|
||||||
p.IncrRunning()
|
p.incrRunning()
|
||||||
}
|
}
|
||||||
return w
|
return w
|
||||||
}
|
}
|
||||||
|
|
10
pool_func.go
10
pool_func.go
|
@ -134,13 +134,13 @@ func (p *PoolWithFunc) Running() int {
|
||||||
return int(atomic.LoadInt32(&p.running))
|
return int(atomic.LoadInt32(&p.running))
|
||||||
}
|
}
|
||||||
|
|
||||||
// IncrRunning increases the number of the currently running goroutines
|
// incrRunning increases the number of the currently running goroutines
|
||||||
func (p *PoolWithFunc) IncrRunning() {
|
func (p *PoolWithFunc) incrRunning() {
|
||||||
atomic.AddInt32(&p.running, 1)
|
atomic.AddInt32(&p.running, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DecrRunning decreases the number of the currently running goroutines
|
// decrRunning decreases the number of the currently running goroutines
|
||||||
func (p *PoolWithFunc) DecrRunning() {
|
func (p *PoolWithFunc) decrRunning() {
|
||||||
atomic.AddInt32(&p.running, -1)
|
atomic.AddInt32(&p.running, -1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,7 +220,7 @@ func (p *PoolWithFunc) getWorker() *WorkerWithFunc {
|
||||||
args: make(chan interface{}, 1),
|
args: make(chan interface{}, 1),
|
||||||
}
|
}
|
||||||
w.run()
|
w.run()
|
||||||
p.IncrRunning()
|
p.incrRunning()
|
||||||
}
|
}
|
||||||
return w
|
return w
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ func (w *Worker) run() {
|
||||||
go func() {
|
go func() {
|
||||||
for f := range w.task {
|
for f := range w.task {
|
||||||
if f == nil {
|
if f == nil {
|
||||||
w.pool.DecrRunning()
|
w.pool.decrRunning()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
f()
|
f()
|
||||||
|
|
|
@ -46,7 +46,7 @@ func (w *WorkerWithFunc) run() {
|
||||||
go func() {
|
go func() {
|
||||||
for args := range w.args {
|
for args := range w.args {
|
||||||
if args == nil {
|
if args == nil {
|
||||||
w.pool.DecrRunning()
|
w.pool.decrRunning()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.pool.poolFunc(args)
|
w.pool.poolFunc(args)
|
||||||
|
|
Loading…
Reference in New Issue