kernel: RingBuffer template class, with everything needed for POSIX select()/poll() bar triggering MonitorEvents.

This will be particularly useful for psuedo-terminal support, especially
once MonitorEvent support is added as this will mean we get select() and
poll() for the PTY ring buffers basically out of the box.