Package com.lucimber.dbus.util
Class ByteBufferPoolManager
java.lang.Object
com.lucimber.dbus.util.ByteBufferPoolManager
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 Summary
Modifier and TypeMethodDescriptionAcquires a ByteBuffer with at least the requested capacity.void
clear()
Clears the pool and resets metrics.static ByteBufferPoolManager
Gets the singleton instance of ByteBufferPoolManager.Gets performance metrics for the buffer pool.void
release
(ByteBuffer buffer) Returns a ByteBuffer to the pool for potential reuse.void
Resets all performance metrics.
-
Method Details
-
getInstance
Gets the singleton instance of ByteBufferPoolManager.- Returns:
- the singleton instance
-
acquire
Acquires a ByteBuffer with at least the requested capacity.- Parameters:
capacity
- minimum required capacityorder
- byte order for the buffer- Returns:
- a ByteBuffer ready for use
-
release
Returns a ByteBuffer to the pool for potential reuse.- Parameters:
buffer
- the buffer to return (may be null)
-
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.
-