Class ResizableMultiReaderRingBuffer<T>


  • public class ResizableMultiReaderRingBuffer<T>
    extends java.lang.Object
    INTERNAL API A mutable RingBuffer that can grow in size and supports multiple readers. Contrary to many other ring buffer implementations this one does not automatically overwrite the oldest elements, rather, if full, the buffer tries to grow and rejects further writes if max capacity is reached.
    • Method Detail

      • size

        public int size()
        The number of elements currently in the buffer.
      • isEmpty

        public boolean isEmpty()
      • nonEmpty

        public boolean nonEmpty()
      • immediatelyAvailable

        public int immediatelyAvailable()
        The number of elements the buffer can still take without having to be resized.
      • maxAvailable

        public int maxAvailable()
        The maximum number of elements the buffer can still take.
      • write

        public boolean write​(T value)
        Tries to write the given value into the buffer thereby potentially growing the backing array. Returns true if the write was successful and false if the buffer is full and cannot grow anymore.
      • read

        public T read​(ResizableMultiReaderRingBuffer.Cursor cursor)
        Tries to read from the buffer using the given Cursor. If there are no more data to be read (i.e. the cursor is already at writeIx) the method throws ResizableMultiReaderRingBuffer.NothingToReadException!
      • underlyingArray

        protected java.lang.Object[] underlyingArray()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object