change internal constant varibale names for package gqueue
@@ -35,10 +35,8 @@ type Queue struct {
}
const (
- // Size for queue buffer.
- gDEFAULT_QUEUE_SIZE = 10000
- // Max batch size per-fetching from list.
- gDEFAULT_MAX_BATCH_SIZE = 10
+ defaultQueueSize = 10000 // Size for queue buffer.
+ defaultBatchSize = 10 // Max batch size per-fetching from list.
)
// New returns an empty queue object.
@@ -54,7 +52,7 @@ func New(limit ...int) *Queue {
} else {
q.list = glist.New(true)
q.events = make(chan struct{}, math.MaxInt32)
- q.C = make(chan interface{}, gDEFAULT_QUEUE_SIZE)
+ q.C = make(chan interface{}, defaultQueueSize)
go q.asyncLoopFromListToChannel()
}
return q
@@ -72,8 +70,8 @@ func (q *Queue) asyncLoopFromListToChannel() {
<-q.events
for !q.closed.Val() {
if length := q.list.Len(); length > 0 {
- if length > gDEFAULT_MAX_BATCH_SIZE {
- length = gDEFAULT_MAX_BATCH_SIZE
+ if length > defaultBatchSize {
+ length = defaultBatchSize
}
for _, v := range q.list.PopFronts(length) {
// When q.C is closed, it will panic here, especially q.C is being blocked for writing.
@@ -101,7 +99,7 @@ func (q *Queue) Push(v interface{}) {
q.C <- v
} else {
q.list.PushBack(v)
- if len(q.events) < gDEFAULT_QUEUE_SIZE {
+ if len(q.events) < defaultQueueSize {
q.events <- struct{}{}
}
}
@@ -124,7 +122,7 @@ func (q *Queue) Close() {
if q.limit > 0 {
close(q.C)
}
- for i := 0; i < gDEFAULT_MAX_BATCH_SIZE; i++ {
+ for i := 0; i < defaultBatchSize; i++ {
q.Pop()
}
}
