io.undertow.server.handlers.cache

## 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

### Nested Class Summary

Nested Classes
`static class` `LimitedBufferSlicePool.PooledByteBuffer`

### Constructor Summary

Constructors
Constructor and Description
`LimitedBufferSlicePool(org.xnio.BufferAllocator<ByteBuffer> allocator, int bufferSize, int maxRegionSize)` Construct a new instance.
`LimitedBufferSlicePool(org.xnio.BufferAllocator<ByteBuffer> allocator, int bufferSize, int maxRegionSize, int maxRegions)` Construct a new instance.
`LimitedBufferSlicePool(int bufferSize, int maxRegionSize)` Construct a new instance, using a direct buffer allocator.

### Method Summary

All Methods Instance Methods Concrete Methods
`LimitedBufferSlicePool.PooledByteBuffer` `allocate()` Allocates a new byte buffer if possible
`boolean` `canAllocate(int slices)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### 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 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)