From 7be597c9e81a1c998e5d5d89f75afe811a9fda20 Mon Sep 17 00:00:00 2001 From: Andy Pan Date: Fri, 9 Jun 2023 00:12:59 +0800 Subject: [PATCH] chore: code cleanup --- pool.go | 4 ++-- pool_func.go | 4 ++-- worker_loop_queue_test.go | 2 +- worker_queue.go | 2 +- worker_stack_test.go | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pool.go b/pool.go index 01241b7..d4750a0 100644 --- a/pool.go +++ b/pool.go @@ -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) diff --git a/pool_func.go b/pool_func.go index 5e8ebc7..96c8831 100644 --- a/pool_func.go +++ b/pool_func.go @@ -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) diff --git a/worker_loop_queue_test.go b/worker_loop_queue_test.go index 1a36031..3bd495e 100644 --- a/worker_loop_queue_test.go +++ b/worker_loop_queue_test.go @@ -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) diff --git a/worker_queue.go b/worker_queue.go index 17c08a4..bcb7480 100644 --- a/worker_queue.go +++ b/worker_queue.go @@ -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) diff --git a/worker_stack_test.go b/worker_stack_test.go index 39bc91b..6fd3d76 100644 --- a/worker_stack_test.go +++ b/worker_stack_test.go @@ -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()})