Top Description Inners Fields Constructors Methods
io.undertow.server.handlers.cache

public final Class LimitedBufferSlicePool

extends Object
Class Inheritance
Static Imports
org.wildfly.common.Assert.checkNotNullParam

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.
Authors
David M. Lloyd, Jason T. Greene

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
private static class

Field Summary

Modifier and TypeField and Description
private final BufferAllocator<ByteBuffer>
private final int
private final int
private final int
private volatile int
private static final AtomicIntegerFieldUpdater<T>
private final Queue<LimitedBufferSlicePool.Slice>

Constructor Summary

AccessConstructor and Description
public
LimitedBufferSlicePool(final BufferAllocator<ByteBuffer>
the buffer allocator to use
allocator
,
final int
the size of each buffer
bufferSize
,
final int
the maximum region size for each backing buffer
maxRegionSize
,
final int
the maximum regions to create, zero for unlimited
maxRegions
)

Construct a new instance.

public
LimitedBufferSlicePool(BufferAllocator<ByteBuffer>
the buffer allocator to use
allocator
,
int
the size of each buffer
bufferSize
,
int
the maximum region size for each backing buffer
maxRegionSize
)

Construct a new instance.

public
LimitedBufferSlicePool(final int
the size of each buffer
bufferSize
,
final int
the maximum region size for each backing buffer
maxRegionSize
)

Construct a new instance, using a direct buffer allocator.

Method Summary

Modifier and TypeMethod and Description
public LimitedBufferSlicePool.PooledByteBuffer

Returns:

new buffer or null if none available
allocate
()

Allocates a new byte buffer if possible

public boolean
canAllocate(int slices)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allocatorback to summary
private final BufferAllocator<ByteBuffer> allocator
bufferSizeback to summary
private final int bufferSize
buffersPerRegionback to summary
private final int buffersPerRegion
maxRegionsback to summary
private final int maxRegions
regionsUsedback to summary
private volatile int regionsUsed
regionUpdaterback to summary
private static final AtomicIntegerFieldUpdater<T> regionUpdater
sliceQueueback to summary
private final Queue<LimitedBufferSlicePool.Slice> sliceQueue

Constructor Detail

LimitedBufferSlicePoolback to summary
public LimitedBufferSlicePool(final BufferAllocator<ByteBuffer> allocator, final int bufferSize, final int maxRegionSize, final int maxRegions)

Construct a new instance.

Parameters
allocator:BufferAllocator<ByteBuffer>

the buffer allocator to use

bufferSize:int

the size of each buffer

maxRegionSize:int

the maximum region size for each backing buffer

maxRegions:int

the maximum regions to create, zero for unlimited

LimitedBufferSlicePoolback to summary
public LimitedBufferSlicePool(BufferAllocator<ByteBuffer> allocator, int bufferSize, int maxRegionSize)

Construct a new instance.

Parameters
allocator:BufferAllocator<ByteBuffer>

the buffer allocator to use

bufferSize:int

the size of each buffer

maxRegionSize:int

the maximum region size for each backing buffer

LimitedBufferSlicePoolback to summary
public LimitedBufferSlicePool(final int bufferSize, final int maxRegionSize)

Construct a new instance, using a direct buffer allocator.

Parameters
bufferSize:int

the size of each buffer

maxRegionSize:int

the maximum region size for each backing buffer

Method Detail

allocateback to summary
public LimitedBufferSlicePool.PooledByteBuffer allocate()

Allocates a new byte buffer if possible

Returns:LimitedBufferSlicePool.PooledByteBuffer

new buffer or null if none available

canAllocateback to summary
public boolean canAllocate(int slices)
io.undertow.server.handlers.cache back to summary

public final Class LimitedBufferSlicePool.PooledByteBuffer

extends Object
Class Inheritance
  • java.lang.Object
  • io.undertow.server.handlers.cache.LimitedBufferSlicePool.PooledByteBuffer

Field Summary

Modifier and TypeField and Description
pack-priv volatile ByteBuffer
private static final AtomicReferenceFieldUpdater<LimitedBufferSlicePool.PooledByteBuffer, ByteBuffer>
private final LimitedBufferSlicePool.Slice
private final Queue<LimitedBufferSlicePool.Slice>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
free()

public ByteBuffer
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

bufferback to summary
pack-priv volatile ByteBuffer buffer
bufferUpdaterback to summary
private static final AtomicReferenceFieldUpdater<LimitedBufferSlicePool.PooledByteBuffer, ByteBuffer> bufferUpdater
regionback to summary
private final LimitedBufferSlicePool.Slice region
slicesback to summary
private final Queue<LimitedBufferSlicePool.Slice> slices

Constructor Detail

PooledByteBufferback to summary
private PooledByteBuffer(final LimitedBufferSlicePool.Slice region, final ByteBuffer buffer, final Queue<LimitedBufferSlicePool.Slice> slices)

Method Detail

freeback to summary
public void free()
getBufferback to summary
public ByteBuffer getBuffer()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

io.undertow.server.handlers.cache back to summary

private final Class LimitedBufferSlicePool.Slice

extends Object
Class Inheritance
  • java.lang.Object
  • io.undertow.server.handlers.cache.LimitedBufferSlicePool.Slice

Field Summary

Modifier and TypeField and Description
private final ByteBuffer
private final int
private final int

Constructor Summary

AccessConstructor and Description
private
Slice(final ByteBuffer parent, final int start, final int size)

Method Summary

Modifier and TypeMethod and Description
pack-priv ByteBuffer
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

parentback to summary
private final ByteBuffer parent
sizeback to summary
private final int size
startback to summary
private final int start

Constructor Detail

Sliceback to summary
private Slice(final ByteBuffer parent, final int start, final int size)

Method Detail

sliceback to summary
pack-priv ByteBuffer slice()