Skip to content

Commit

Permalink
chore: code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
panjf2000 committed Jun 8, 2023
1 parent 67b3a7a commit 7be597c
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ func NewPool(size int, options ...Option) (*Pool, error) {
if size == -1 {
return nil, ErrInvalidPreAllocSize
}
p.workers = newWorkerArray(queueTypeLoopQueue, size)
p.workers = newWorkerQueue(queueTypeLoopQueue, size)
} else {
p.workers = newWorkerArray(queueTypeStack, 0)
p.workers = newWorkerQueue(queueTypeStack, 0)
}

p.cond = sync.NewCond(p.lock)
Expand Down
4 changes: 2 additions & 2 deletions pool_func.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ func NewPoolWithFunc(size int, pf func(interface{}), options ...Option) (*PoolWi
if size == -1 {
return nil, ErrInvalidPreAllocSize
}
p.workers = newWorkerArray(queueTypeLoopQueue, size)
p.workers = newWorkerQueue(queueTypeLoopQueue, size)
} else {
p.workers = newWorkerArray(queueTypeStack, 0)
p.workers = newWorkerQueue(queueTypeStack, 0)
}

p.cond = sync.NewCond(p.lock)
Expand Down
2 changes: 1 addition & 1 deletion worker_loop_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestLoopQueue(t *testing.T) {
assert.EqualValuesf(t, 6, q.len(), "Len error: %d", q.len())
}

func TestRotatedArraySearch(t *testing.T) {
func TestRotatedQueueSearch(t *testing.T) {
size := 10
q := newWorkerLoopQueue(size)

Expand Down
2 changes: 1 addition & 1 deletion worker_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const (
queueTypeLoopQueue
)

func newWorkerArray(qType queueType, size int) workerQueue {
func newWorkerQueue(qType queueType, size int) workerQueue {
switch qType {
case queueTypeStack:
return newWorkerStack(size)
Expand Down
2 changes: 1 addition & 1 deletion worker_stack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestNewWorkerStack(t *testing.T) {
}

func TestWorkerStack(t *testing.T) {
q := newWorkerArray(queueType(-1), 0)
q := newWorkerQueue(queueType(-1), 0)

for i := 0; i < 5; i++ {
err := q.insert(&goWorker{lastUsed: time.Now()})
Expand Down

0 comments on commit 7be597c

Please sign in to comment.