Class ByteBufferPoolManager

java.lang.Object
com.lucimber.dbus.util.ByteBufferPoolManager

public final class ByteBufferPoolManager extends Object
A singleton manager for ByteBuffer pooling with performance metrics.

This manager provides a global instance of ByteBufferPool and tracks performance metrics to help identify optimization opportunities.

  • Method Details

    • getInstance

      public static ByteBufferPoolManager getInstance()
      Gets the singleton instance of ByteBufferPoolManager.
      Returns:
      the singleton instance
    • acquire

      public ByteBuffer acquire(int capacity, ByteOrder order)
      Acquires a ByteBuffer with at least the requested capacity.
      Parameters:
      capacity - minimum required capacity
      order - byte order for the buffer
      Returns:
      a ByteBuffer ready for use
    • release

      public void release(ByteBuffer buffer)
      Returns a ByteBuffer to the pool for potential reuse.
      Parameters:
      buffer - the buffer to return (may be null)
    • getPerformanceMetrics

      public String getPerformanceMetrics()
      Gets performance metrics for the buffer pool.
      Returns:
      a formatted string with performance statistics
    • resetMetrics

      public void resetMetrics()
      Resets all performance metrics. Useful for testing or monitoring specific periods.
    • clear

      public void clear()
      Clears the pool and resets metrics.