Class LimitedBufferSlicePool
- java.lang.Object
-
- io.undertow.server.handlers.cache.LimitedBufferSlicePool
-
public final class LimitedBufferSlicePool extends java.lang.ObjectA 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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLimitedBufferSlicePool.PooledByteBuffer
-
Constructor Summary
Constructors Constructor Description LimitedBufferSlicePool(int bufferSize, int maxRegionSize)Construct a new instance, using a direct buffer allocator.LimitedBufferSlicePool(org.xnio.BufferAllocator<java.nio.ByteBuffer> allocator, int bufferSize, int maxRegionSize)Construct a new instance.LimitedBufferSlicePool(org.xnio.BufferAllocator<java.nio.ByteBuffer> allocator, int bufferSize, int maxRegionSize, int maxRegions)Construct a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LimitedBufferSlicePool.PooledByteBufferallocate()Allocates a new byte buffer if possiblebooleancanAllocate(int slices)
-
-
-
Constructor Detail
-
LimitedBufferSlicePool
public LimitedBufferSlicePool(org.xnio.BufferAllocator<java.nio.ByteBuffer> allocator, int bufferSize, int maxRegionSize, int maxRegions)Construct a new instance.- Parameters:
allocator- the buffer allocator to usebufferSize- the size of each buffermaxRegionSize- the maximum region size for each backing buffermaxRegions- the maximum regions to create, zero for unlimited
-
LimitedBufferSlicePool
public LimitedBufferSlicePool(org.xnio.BufferAllocator<java.nio.ByteBuffer> allocator, int bufferSize, int maxRegionSize)Construct a new instance.- Parameters:
allocator- the buffer allocator to usebufferSize- the size of each buffermaxRegionSize- 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 buffermaxRegionSize- the maximum region size for each backing buffer
-
-
Method Detail
-
allocate
public LimitedBufferSlicePool.PooledByteBuffer allocate()
Allocates a new byte buffer if possible- Returns:
- new buffer or null if none available
-
canAllocate
public boolean canAllocate(int slices)
-
-