Ring Buffers: Building O(1) Queues on Arrays