Pushes/inserts a value at the end/tail of the queue. Note: this function does mutate the queue. go-routine safe.
(item interface{})
| 67 | // Note: this function does mutate the queue. |
| 68 | // go-routine safe. |
| 69 | func (q *Queue) Push(item interface{}) { |
| 70 | q.lock.Lock() |
| 71 | defer q.lock.Unlock() |
| 72 | |
| 73 | n := &queuenode{data: item} |
| 74 | |
| 75 | if q.tail == nil { |
| 76 | q.tail = n |
| 77 | q.head = n |
| 78 | } else { |
| 79 | q.tail.next = n |
| 80 | q.tail = n |
| 81 | } |
| 82 | q.count++ |
| 83 | } |
| 84 | |
| 85 | // Returns the value at the front of the queue. |
| 86 | // i.e. the oldest value in the queue. |
no outgoing calls
no test coverage detected