Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ListQueue ¶
type ListQueue struct {
// contains filtered or unexported fields
}
ListQueue 是一个列表任务队列,用于在高并发情况下缓解服务器压力并改进任务处理
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 NewListQueueWithMaxLen ¶
NewListQueueWithMaxLen 创建一个列表队列,指定工作线程数和最大元素数
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue 任务队列排队以在高并发情况下减轻服务器压力并改进任务处理
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.