Class LimitedBufferSlicePool
java.lang.Object
io.undertow.server.handlers.cache.LimitedBufferSlicePool
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
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionLimitedBufferSlicePool(int bufferSize, int maxRegionSize) Construct a new instance, using a direct buffer allocator.LimitedBufferSlicePool(io.netty.buffer.ByteBufAllocator allocator, int bufferSize, int maxRegionSize) Construct a new instance.LimitedBufferSlicePool(io.netty.buffer.ByteBufAllocator allocator, int bufferSize, int maxRegionSize, int maxRegions) Construct a new instance. -
Method Summary
Modifier and TypeMethodDescriptionallocate()Allocates a new byte buffer if possiblebooleancanAllocate(int slices)
-
Constructor Details
-
LimitedBufferSlicePool
public LimitedBufferSlicePool(io.netty.buffer.ByteBufAllocator 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(io.netty.buffer.ByteBufAllocator 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 Details
-
allocate
Allocates a new byte buffer if possible- Returns:
- new buffer or null if none available
-
canAllocate
public boolean canAllocate(int slices)
-