Class SimpleCachedBufferPool


  • public class SimpleCachedBufferPool
    extends java.lang.Object
    A very simple Bytebuffer pool with a fixed allocation size and a cached max allocation count. Will allow you to go past the "max", freeing all buffers allocated beyond the max buffer count on release. Has a reusable thread local ByteBuffer that users can make use of.
    • Constructor Detail

      • SimpleCachedBufferPool

        public SimpleCachedBufferPool​(int maxBufferPoolSize,
                                      int bufferSize,
                                      BufferType preferredReusableBufferType)
    • Method Detail

      • createBuffer

        public java.nio.ByteBuffer createBuffer()
      • getThreadLocalReusableBuffer

        public java.nio.ByteBuffer getThreadLocalReusableBuffer​(int size)
      • releaseBuffer

        public void releaseBuffer​(java.nio.ByteBuffer buffer)
      • emptyBufferPool

        public void emptyBufferPool()
        Empties the buffer pool.
      • atLimit

        public boolean atLimit()
        Checks if the number of used buffers has exceeded the maximum number of cached buffers.
        Returns:
        true if the number of used buffers has exceeded the maximum number of cached buffers, false otherwise.
      • toString

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