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.
        Returns:
        (undocumented)
      • 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.
        Returns:
        (undocumented)
      • maxAvailable

        public int maxAvailable()
        The maximum number of elements the buffer can still take.
        Returns:
        (undocumented)
      • count

        public int count​(ResizableMultiReaderRingBuffer.Cursor cursor)
        Returns the number of elements that the buffer currently contains for the given cursor.
        Parameters:
        cursor - (undocumented)
        Returns:
        (undocumented)
      • initCursor

        public void initCursor​(ResizableMultiReaderRingBuffer.Cursor cursor)
        Initializes the given Cursor to the oldest buffer entry that is still available.
        Parameters:
        cursor - (undocumented)
      • 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.
        Parameters:
        value - (undocumented)
        Returns:
        (undocumented)
      • 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!
        Parameters:
        cursor - (undocumented)
        Returns:
        (undocumented)
      • underlyingArray

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

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