Terminate terminate the queue to receive the task and release the resource
()
| 51 | |
| 52 | // Terminate terminate the queue to receive the task and release the resource |
| 53 | func (q *Queue) Terminate() { |
| 54 | if atomic.LoadUint32(&q.running) != 1 { |
| 55 | return |
| 56 | } |
| 57 | |
| 58 | atomic.StoreUint32(&q.running, 0) |
| 59 | q.wg.Wait() |
| 60 | |
| 61 | close(q.jobQueue) |
| 62 | for i := 0; i < q.maxWorkers; i++ { |
| 63 | q.workers[i].Stop() |
| 64 | } |
| 65 | close(q.workerPool) |
| 66 | } |
| 67 | |
| 68 | // Push put the executable task into the queue |
| 69 | func (q *Queue) Push(job Jober) { |