| 10 | explicit ringbuffer() : begin(0), end(0), wrap(false) {} |
| 11 | |
| 12 | void push(const T *data) { |
| 13 | |
| 14 | memcpy(buffer + end, data, sizeof(T)); |
| 15 | // If going to wrap, push start along to maintain order |
| 16 | if (begin == end && wrap) { |
| 17 | begin = (begin + 1) % size; |
| 18 | } |
| 19 | end = (end + 1) % size; |
| 20 | if (begin == end) { |
| 21 | wrap = true; |
| 22 | } |
| 23 | } |
| 24 | // Give null to just drop the data |
| 25 | void pop(T *dest) { |
| 26 | if (getOccupied() == 0) { |
no outgoing calls