Class LimitedBufferSlicePool

java.lang.Object
io.undertow.server.handlers.cache.LimitedBufferSlicePool

public final class LimitedBufferSlicePool extends Object
A limited 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.
Author:
David M. Lloyd, Jason T. Greene
  • Constructor Details

    • LimitedBufferSlicePool

      public LimitedBufferSlicePool(org.xnio.BufferAllocator<ByteBuffer> allocator, int bufferSize, int maxRegionSize, int maxRegions)
      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
      maxRegions - the maximum regions to create, zero for unlimited
    • LimitedBufferSlicePool

      public LimitedBufferSlicePool(org.xnio.BufferAllocator<ByteBuffer> allocator, int bufferSize, int maxRegionSize)
      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
    • LimitedBufferSlicePool

      public LimitedBufferSlicePool(int bufferSize, int maxRegionSize)
      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

      Allocates a new byte buffer if possible
      Returns:
      new buffer or null if none available
    • canAllocate

      public boolean canAllocate(int slices)