Interface RingBuffer

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
RingBufferImpl

public interface RingBuffer extends AutoCloseable
A primitive int-based ring buffer (circular queue) backed by off-heap memory.

Designed for zero-allocation passing of indices (pointers) between threads. Implementations should support Single-Producer/Single-Consumer (SPSC) or Multi-Producer/Multi-Consumer (MPMC) semantics as needed.

  • Method Summary

    Modifier and Type
    Method
    Description
    int
    The total capacity of the ring.
    void
    Releases the underlying off-heap memory.
    boolean
     
    boolean
     
    boolean
    offer(int item)
    Offers an item to the ring.
    int
    Polls an item from the ring.
    int
    The current number of items in the ring.
  • Method Details

    • offer

      boolean offer(int item)
      Offers an item to the ring.
      Parameters:
      item - The item (index) to enqueue.
      Returns:
      true if successful, false if full.
    • poll

      int poll()
      Polls an item from the ring.
      Returns:
      The item, or -1 (or a configured sentinel) if empty.
    • capacity

      int capacity()
      The total capacity of the ring.
    • size

      int size()
      The current number of items in the ring.
    • isEmpty

      boolean isEmpty()
    • isFull

      boolean isFull()
    • close

      void close()
      Releases the underlying off-heap memory.
      Specified by:
      close in interface AutoCloseable