Close signals that the queue should be closed when it is empty. A closed queue will not accept new items.
()
| 62 | // Close signals that the queue should be closed when it is empty. |
| 63 | // A closed queue will not accept new items. |
| 64 | func (pq *PriorityQueue) Close() { |
| 65 | pq.lock.Lock() |
| 66 | defer pq.lock.Unlock() |
| 67 | if len(pq.queue) > 0 { |
| 68 | pq.closing = true |
| 69 | } else { |
| 70 | pq.closed = true |
| 71 | } |
| 72 | pq.cond.Broadcast() |
| 73 | } |
| 74 | |
| 75 | // DiscardAndClose closes the queue and removes all the items from it. |
| 76 | func (pq *PriorityQueue) DiscardAndClose() { |