Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Run ¶
func Run(maxCapacity, maxThread int)
Run start running queues, specify the number of buffers, and the number of worker threads
func RunListQueue ¶ added in v1.2.0
func RunListQueue(maxThread int)
RunListQueue start running list queues ,specify the number of worker threads
Types ¶
type ListQueue ¶ added in v1.2.0
type ListQueue struct {
// contains filtered or unexported fields
}
ListQueue a list task queue for mitigating server pressure in high concurrency situations and improving task processing
Example ¶
q := NewListQueue(10) q.Run() var count int64 for i := 0; i < 10; i++ { job := NewJob("foo", func(v interface{}) { atomic.AddInt64(&count, 1) }) q.Push(job) } q.Terminate() fmt.Println(count)
Output: 10
func NewListQueue ¶ added in v1.2.0
NewListQueue create a list queue that specifies the number of worker threads
func NewListQueueWithMaxLen ¶ added in v1.2.0
NewListQueueWithMaxLen create a list queue that specifies the number of worker threads and the maximum number of elements
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue a task queue for mitigating server pressure in high concurrency situations and improving task processing
Example ¶
q := NewQueue(1, 10) q.Run() var count int64 for i := 0; i < 10; i++ { job := NewJob("foo", func(v interface{}) { atomic.AddInt64(&count, 1) }) q.Push(job) } q.Terminate() fmt.Println(count)
Output: 10
Click to show internal directories.
Click to hide internal directories.