NewListQueueWithMaxLen create a list queue that specifies the number of worker threads and the maximum number of elements
(maxThread, maxLen int)
| 15 | // NewListQueueWithMaxLen create a list queue that specifies the number of worker threads |
| 16 | // and the maximum number of elements |
| 17 | func NewListQueueWithMaxLen(maxThread, maxLen int) *ListQueue { |
| 18 | return &ListQueue{ |
| 19 | maxLen: maxLen, |
| 20 | maxWorker: maxThread, |
| 21 | workers: make([]*worker, maxThread), |
| 22 | workerPool: make(chan chan Jober, maxThread), |
| 23 | list: list.New(), |
| 24 | lock: new(sync.RWMutex), |
| 25 | wg: new(sync.WaitGroup), |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | // ListQueue a list task queue for mitigating server pressure in high concurrency situations |
| 30 | // and improving task processing |