Fix ringbuffer.

Make access to count_ member atomic and change in_ and out_ index
overflow handling.