mirror of https://github.com/panjf2000/ants.git
remove some comments
This commit is contained in:
parent
ab6390f6d0
commit
07f98b4ac6
2
pool.go
2
pool.go
|
@ -126,6 +126,8 @@ func (p *Pool) getWorker() *Worker {
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
if p.running >= p.capacity {
|
if p.running >= p.capacity {
|
||||||
waiting = true
|
waiting = true
|
||||||
|
} else {
|
||||||
|
p.running++
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
w = workers[n]
|
w = workers[n]
|
||||||
|
|
|
@ -40,7 +40,7 @@ type Worker struct {
|
||||||
// run will start a goroutine to repeat the process
|
// run will start a goroutine to repeat the process
|
||||||
// that perform the function calls.
|
// that perform the function calls.
|
||||||
func (w *Worker) run() {
|
func (w *Worker) run() {
|
||||||
atomic.AddInt32(&w.pool.running, 1)
|
//atomic.AddInt32(&w.pool.running, 1)
|
||||||
go func() {
|
go func() {
|
||||||
for f := range w.task {
|
for f := range w.task {
|
||||||
if f == nil || len(w.pool.release) > 0 {
|
if f == nil || len(w.pool.release) > 0 {
|
||||||
|
|
|
@ -53,26 +53,6 @@ func (w *WorkerWithFunc) run() {
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
//func (w *WorkerWithFunc) run() {
|
|
||||||
// atomic.AddInt32(&w.pool.running, 1)
|
|
||||||
// go func() {
|
|
||||||
// for {
|
|
||||||
// select {
|
|
||||||
// case args := <-w.args:
|
|
||||||
// if args == nil {
|
|
||||||
// atomic.AddInt32(&w.pool.running, -1)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// w.pool.poolFunc(args)
|
|
||||||
// w.pool.putWorker(w)
|
|
||||||
// case <-w.pool.release:
|
|
||||||
// atomic.AddInt32(&w.pool.running, -1)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }()
|
|
||||||
//}
|
|
||||||
|
|
||||||
// stop this worker.
|
// stop this worker.
|
||||||
func (w *WorkerWithFunc) stop() {
|
func (w *WorkerWithFunc) stop() {
|
||||||
w.args <- nil
|
w.args <- nil
|
||||||
|
|
Loading…
Reference in New Issue