Push put the executable task into the queue
(job Jober)
| 80 | |
| 81 | // Push put the executable task into the queue |
| 82 | func (q *ListQueue) Push(job Jober) { |
| 83 | if atomic.LoadUint32(&q.running) != 1 { |
| 84 | return |
| 85 | } |
| 86 | |
| 87 | if q.maxLen > 0 { |
| 88 | q.lock.RLock() |
| 89 | if q.list.Len() > q.maxLen { |
| 90 | q.lock.RUnlock() |
| 91 | return |
| 92 | } |
| 93 | q.lock.RUnlock() |
| 94 | } |
| 95 | |
| 96 | q.wg.Add(1) |
| 97 | q.lock.Lock() |
| 98 | q.list.PushBack(job) |
| 99 | q.lock.Unlock() |
| 100 | } |
| 101 | |
| 102 | // Terminate terminate the queue to receive the task and release the resource |
| 103 | func (q *ListQueue) Terminate() { |
no outgoing calls