Class LockFreeBufferPool

java.lang.Object
express.mvp.roray.ffm.pool.LockFreeBufferPool
All Implemented Interfaces:
AutoCloseable

public class LockFreeBufferPool extends Object implements AutoCloseable
Lock-free buffer pool using a ring buffer for index tracking.

This pool provides high-performance buffer acquisition without locks, using a ring buffer to track free buffer indices.

  • Constructor Details

    • LockFreeBufferPool

      public LockFreeBufferPool(int count, int bufferSize)
      Creates a new lock-free buffer pool.
      Parameters:
      count - number of buffers (must be a power of 2)
      bufferSize - size of each buffer in bytes
  • Method Details

    • acquire

      public BufferRef acquire()
      Acquires a buffer reference from the pool.
      Returns:
      a BufferRef with refCount=1, or null if the pool is empty
    • capacity

      public int capacity()
    • available

      public int available()
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable