Class ThreadLocalByteBufferHolder


  • public final class ThreadLocalByteBufferHolder
    extends java.lang.Object
    Utility class that allow buffers to be reused by storing them in a thread local instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.nio.ByteBuffer getBuffer​(int size)
      Returns the buffer for the current thread.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ThreadLocalByteBufferHolder

        public ThreadLocalByteBufferHolder​(BufferType bufferType)
    • Method Detail

      • getBuffer

        public java.nio.ByteBuffer getBuffer​(int size)
        Returns the buffer for the current thread.

        If the buffer for the current thread does not have a capacity large enough. A new buffer with the requested size will be instatiated an will replace the existing one.

        Parameters:
        size - the buffer size
        Returns:
        the buffer for the current thread.