Interface ByteBufferPool

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      java.nio.ByteBuffer acquire​(int size, boolean direct)
      Requests a ByteBuffer of the given size.
      default java.nio.ByteBuffer newByteBuffer​(int capacity, boolean direct)
      Creates a new ByteBuffer of the given capacity and the given directness.
      void release​(java.nio.ByteBuffer buffer)
      Returns a ByteBuffer, usually obtained with acquire(int, boolean) (but not necessarily), making it available for recycling and reuse.
      default void remove​(java.nio.ByteBuffer buffer)
      Removes a ByteBuffer that was previously obtained with acquire(int, boolean).
    • Method Detail

      • acquire

        java.nio.ByteBuffer acquire​(int size,
                                    boolean direct)

        Requests a ByteBuffer of the given size.

        The returned buffer may have a bigger capacity than the size being requested but it will have the limit set to the given size.

        Parameters:
        size - the size of the buffer
        direct - whether the buffer must be direct or not
        Returns:
        the requested buffer
        See Also:
        release(ByteBuffer)
      • release

        void release​(java.nio.ByteBuffer buffer)

        Returns a ByteBuffer, usually obtained with acquire(int, boolean) (but not necessarily), making it available for recycling and reuse.

        Parameters:
        buffer - the buffer to return
        See Also:
        acquire(int, boolean)
      • newByteBuffer

        default java.nio.ByteBuffer newByteBuffer​(int capacity,
                                                  boolean direct)

        Creates a new ByteBuffer of the given capacity and the given directness.

        Parameters:
        capacity - the ByteBuffer capacity
        direct - the ByteBuffer directness
        Returns:
        a newly allocated ByteBuffer