Module 
Package org.xnio

Interface BufferAllocator<B extends java.nio.Buffer>

  • Type Parameters:
    B - the buffer type

    public interface BufferAllocator<B extends java.nio.Buffer>
    A simple allocator for buffers.
    Author:
    David M. Lloyd
    • Field Detail

      • BYTE_BUFFER_ALLOCATOR

        static final BufferAllocator<java.nio.ByteBuffer> BYTE_BUFFER_ALLOCATOR
        A simple allocator for heap-array-backed byte buffers.
      • DIRECT_BYTE_BUFFER_ALLOCATOR

        static final BufferAllocator<java.nio.ByteBuffer> DIRECT_BYTE_BUFFER_ALLOCATOR
        A simple allocator for direct byte buffers.
    • Method Detail

      • allocate

        B allocate​(int size)
            throws java.lang.IllegalArgumentException
        Allocate a buffer of the given size.
        Parameters:
        size - the size
        Returns:
        the buffer
        Throws:
        java.lang.IllegalArgumentException - if the given buffer size is less than zero