NewQueue create a queue that specifies the number of buffers and the number of worker threads
(maxCapacity, maxThread int)
| 7 | |
| 8 | // NewQueue create a queue that specifies the number of buffers and the number of worker threads |
| 9 | func NewQueue(maxCapacity, maxThread int) *Queue { |
| 10 | return &Queue{ |
| 11 | jobQueue: make(chan Jober, maxCapacity), |
| 12 | maxWorkers: maxThread, |
| 13 | workerPool: make(chan chan Jober, maxThread), |
| 14 | workers: make([]*worker, maxThread), |
| 15 | wg: new(sync.WaitGroup), |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | // Queue a task queue for mitigating server pressure in high concurrency situations |
| 20 | // and improving task processing |
no outgoing calls