The simplest single-producer single-consumer ring keeps two counters that are never reset and masks them on every access. That shape turns the full and empty tests into one subtraction and takes the modulo off the hot path, but it also pulls the counters' own 64-bit overflow into the correctness of the queue: when an index wraps, the slot it addresses after the wrap has to continue the sequence from before it. That holds only when the capacity divides 2^64. So a power-of-two capacity is a correctness condition rather than a performance preference, and the difference shows up exactly once in the life of a process.
I keep a small header-only version of this queue with the reasoning written down next to the code, spscring . The README opens by listing the three ways these queues are usually wrong, and the third one is this: a counter that wraps at a non-multiple of the capacity, so the queue silently reorders once, years in.…