A ring buffer is a fixed array of slots used circularly: a writer’s position and a reader’s position increase forever and index the array modulo its size, a power of two so that the modulo is a mask. A single-producer single-consumer queue (SPSC) is a ring with exactly one writing thread and one reading thread; each position is written by one thread only, so no compare-and-swap is needed.
bench_rings.py.