From 07f98b4ac6bc55ba7ba199947e5e911b943e3ba7 Mon Sep 17 00:00:00 2001 From: andy pan Date: Thu, 24 May 2018 19:30:18 +0800 Subject: [PATCH] remove some comments --- pool.go | 2 ++ worker.go | 2 +- worker_func.go | 20 -------------------- 3 files changed, 3 insertions(+), 21 deletions(-) diff --git a/pool.go b/pool.go index 5065e3a..05dfe6a 100644 --- a/pool.go +++ b/pool.go @@ -126,6 +126,8 @@ func (p *Pool) getWorker() *Worker { if n < 0 { if p.running >= p.capacity { waiting = true + } else { + p.running++ } } else { w = workers[n] diff --git a/worker.go b/worker.go index 34b3004..ed941b7 100644 --- a/worker.go +++ b/worker.go @@ -40,7 +40,7 @@ type Worker struct { // run will start a goroutine to repeat the process // that perform the function calls. func (w *Worker) run() { - atomic.AddInt32(&w.pool.running, 1) + //atomic.AddInt32(&w.pool.running, 1) go func() { for f := range w.task { if f == nil || len(w.pool.release) > 0 { diff --git a/worker_func.go b/worker_func.go index 4ef969e..3d07f3d 100644 --- a/worker_func.go +++ b/worker_func.go @@ -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. func (w *WorkerWithFunc) stop() { w.args <- nil