Terminate terminate the queue to receive the task and release the resource
()
| 101 | |
| 102 | // Terminate terminate the queue to receive the task and release the resource |
| 103 | func (q *ListQueue) Terminate() { |
| 104 | if atomic.LoadUint32(&q.running) != 1 { |
| 105 | return |
| 106 | } |
| 107 | |
| 108 | atomic.StoreUint32(&q.running, 0) |
| 109 | q.wg.Wait() |
| 110 | |
| 111 | for i := 0; i < q.maxWorker; i++ { |
| 112 | q.workers[i].Stop() |
| 113 | } |
| 114 | close(q.workerPool) |
| 115 | } |