A ring buffer is a fixed array used as a queue: the producer writes at the tail, the consumer reads at the head, and both wrap around to the start. It never allocates after construction and each operation is a few instructions, which is why market data feeds, loggers and network stacks put one between stages.
This design keeps two counters that only ever grow, head_ and tail_, and finds the slot with counter & (N - 1), which is why the capacity is a power of two. The number of items is tail_ - head_; the buffer is empty when they are equal and full when the difference is N. Because the counters never wrap back to the start, full and empty can never be confused, a bug that designs with wrapping indexes work around by leaving one slot always empty.
When the buffer is full the producer must choose: refuse the new item and count the drop, or overwrite the oldest. A price feed usually prefers the newest data; an order queue must never lose one. The tests count heap allocations to make sure pushing and popping never touch the heap.
Two growing counters and a mask: the whole ring buffer.