Package org.xnio

Class ByteBufferSlicePool

java.lang.Object
org.xnio.ByteBufferSlicePool
All Implemented Interfaces:
Pool<ByteBuffer>

public final class ByteBufferSlicePool extends Object implements Pool<ByteBuffer>
Deprecated.
A buffer pooled allocator. This pool uses a series of buffer regions to back the returned pooled buffers. When the buffer is no longer needed, it should be freed back into the pool; failure to do so will cause the corresponding buffer area to be unavailable until the buffer is garbage-collected. If the buffer pool is no longer used, it is advisable to invoke clean() to make sure that direct allocated buffers can be reused by a future instance.
Author:
David M. Lloyd, Flavia Rainone
  • Constructor Details

    • ByteBufferSlicePool

      public ByteBufferSlicePool(BufferAllocator<ByteBuffer> allocator, int bufferSize, int maxRegionSize, int threadLocalQueueSize)
      Deprecated.
      Construct a new instance.
      Parameters:
      allocator - the buffer allocator to use
      bufferSize - the size of each buffer
      maxRegionSize - the maximum region size for each backing buffer
      threadLocalQueueSize - the number of buffers to cache on each thread
    • ByteBufferSlicePool

      public ByteBufferSlicePool(BufferAllocator<ByteBuffer> allocator, int bufferSize, int maxRegionSize)
      Deprecated.
      Construct a new instance.
      Parameters:
      allocator - the buffer allocator to use
      bufferSize - the size of each buffer
      maxRegionSize - the maximum region size for each backing buffer
    • ByteBufferSlicePool

      public ByteBufferSlicePool(int bufferSize, int maxRegionSize)
      Deprecated.
      Construct a new instance, using a direct buffer allocator.
      Parameters:
      bufferSize - the size of each buffer
      maxRegionSize - the maximum region size for each backing buffer
  • Method Details

    • allocate

      public Pooled<ByteBuffer> allocate()
      Deprecated.
      Allocate a resource from the pool.
      Specified by:
      allocate in interface Pool<ByteBuffer>
      Returns:
      the resource
    • clean

      public void clean()
      Deprecated.
      Cleans the pool, removing references to any buffers inside it. Should be invoked on pool disposal, when the pool will no longer be used.
    • getBufferSize

      public int getBufferSize()
      Deprecated.
      Return the size of the ByteBuffers that are returned by allocate().