Generic FIFO buffer implementation