mirror of https://github.com/panjf2000/ants.git
chore: code cleanup
This commit is contained in:
parent
67b3a7a2c3
commit
7be597c9e8
4
pool.go
4
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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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()})
|
||||
|
|
Loading…
Reference in New Issue