Pop reads the oldest entry from queue and moves head pointer to the next one
()
| 161 | |
| 162 | // Pop reads the oldest entry from queue and moves head pointer to the next one |
| 163 | func (q *BytesQueue) Pop() ([]byte, error) { |
| 164 | data, blockSize, err := q.peek(q.head) |
| 165 | if err != nil { |
| 166 | return nil, err |
| 167 | } |
| 168 | |
| 169 | q.head += blockSize |
| 170 | q.count-- |
| 171 | |
| 172 | if q.head == q.rightMargin { |
| 173 | q.head = leftMarginIndex |
| 174 | if q.tail == q.rightMargin { |
| 175 | q.tail = leftMarginIndex |
| 176 | } |
| 177 | q.rightMargin = q.tail |
| 178 | } |
| 179 | |
| 180 | q.full = false |
| 181 | |
| 182 | return data, nil |
| 183 | } |
| 184 | |
| 185 | // Peek reads the oldest entry from list without moving head pointer |
| 186 | func (q *BytesQueue) Peek() ([]byte, error) { |