summaryrefslogtreecommitdiff
path: root/static_pool.go
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2018-07-23 23:07:49 +0300
committerGitHub <[email protected]>2018-07-23 23:07:49 +0300
commitb79eda8ae15be121d085c367c4f18865d45a243d (patch)
tree48ec0e200847d5cf41e278ccb2052042f6aa5436 /static_pool.go
parent7722c25c4dee179f6db7c696662d16e063d815f9 (diff)
Update static_pool.go
Diffstat (limited to 'static_pool.go')
-rw-r--r--static_pool.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/static_pool.go b/static_pool.go
index b974ac90..95d2fe14 100644
--- a/static_pool.go
+++ b/static_pool.go
@@ -159,13 +159,15 @@ func (p *StaticPool) Destroy() {
wg.Wait()
}
-// finds free worker in a given time interval or creates new if allowed.
+// finds free worker in a given time interval. Skips dead workers.
func (p *StaticPool) allocateWorker() (w *Worker, err error) {
for i := atomic.LoadInt64(&p.numDead); i >= 0; i++ {
- // this loop is required to skip issues with dead workers still being in a ring.
+ // this loop is required to skip issues with dead workers still being in a ring
+ // (we know how many workers).
select {
case w = <-p.free:
if w.State().Value() != StateReady {
+ // found expected dead worker
atomic.AddInt64(&p.numDead, ^int64(0))
continue
}