ex 1.3.39 RingBuffer, with tests