Skip to content

Commit

Permalink
gpool
Browse files Browse the repository at this point in the history
  • Loading branch information
snail007 committed Jan 5, 2024
1 parent 048e5cf commit 603f64f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions util/gpool/gpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ func (s *Pool) Stop() {
s.workers.Clear()
}

// RunningWorkCount returns the count of running workers
func (s *Pool) RunningWorkCount() (workerCount int) {
// RunningWorkerCount returns the count of running workers
func (s *Pool) RunningWorkerCount() (workerCount int) {
return int(atomic.LoadInt64(s.runningWorkerCounter))
}

Expand Down
10 changes: 5 additions & 5 deletions util/gpool/gpool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ func TestRunning(t *testing.T) {
time.Sleep(time.Second)
})
time.Sleep(time.Millisecond * 40)
if p.RunningWorkCount() == 3 {
if p.RunningWorkerCount() == 3 {
t.Log("Running is okay")
} else {
t.Fatalf("Running is failed")
Expand All @@ -247,7 +247,7 @@ func TestIncrease(t *testing.T) {
})
}
time.Sleep(time.Second)
assert.Equal(6, p.RunningWorkCount())
assert.Equal(6, p.RunningWorkerCount())
p.Stop()
}

Expand All @@ -261,10 +261,10 @@ func TestDecrease(t *testing.T) {
})
}
time.Sleep(time.Millisecond * 30)
assert.Equal(2, p.RunningWorkCount())
assert.Equal(2, p.RunningWorkerCount())
p.Decrease(1)
time.Sleep(time.Second)
assert.Equal(1, p.RunningWorkCount())
assert.Equal(1, p.RunningWorkerCount())
p.Stop()
}

Expand Down Expand Up @@ -333,7 +333,7 @@ func TestGPool_MaxWaitCount(t *testing.T) {

time.Sleep(time.Millisecond * 40)
assert.Equal(0, p.IdleWorkerCount())
assert.Equal(1, p.RunningWorkCount())
assert.Equal(1, p.RunningWorkerCount())
p.Stop()
}

Expand Down

0 comments on commit 603f64f

Please sign in to comment.