Class IoUringAdaptiveBufferRingAllocator
java.lang.Object
io.netty.channel.uring.AbstractIoUringBufferRingAllocator
io.netty.channel.uring.IoUringAdaptiveBufferRingAllocator
- All Implemented Interfaces:
IoUringBufferRingAllocator
IoUringBufferRingAllocator implementation which uses an adaptive strategy to allocate buffers, which
will decrease / increase the buffer size depending on if the allocated buffers were completely used or not before.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AdaptiveCalculatorstatic final intstatic final intstatic final int -
Constructor Summary
ConstructorsConstructorDescriptionCreates new instance.IoUringAdaptiveBufferRingAllocator(ByteBufAllocator allocator, int minimum, int initial, int maximum) Creates new instance.IoUringAdaptiveBufferRingAllocator(ByteBufAllocator allocator, int minimum, int initial, int maximum, boolean largeAllocation) Creates new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidlastBytesRead(int attempted, int actual) Does nothing by default, sub-classes might override this.protected intReturn the next buffer size of eachByteBufthat is put into the buffer ring.Methods inherited from class AbstractIoUringBufferRingAllocator
allocate, allocateBatchMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
DEFAULT_MINIMUM
public static final int DEFAULT_MINIMUM- See Also:
-
DEFAULT_INITIAL
public static final int DEFAULT_INITIAL- See Also:
-
DEFAULT_MAXIMUM
public static final int DEFAULT_MAXIMUM- See Also:
-
calculator
-
-
Constructor Details
-
IoUringAdaptiveBufferRingAllocator
public IoUringAdaptiveBufferRingAllocator() -
IoUringAdaptiveBufferRingAllocator
Creates new instance.- Parameters:
allocator- theByteBufAllocatorto use.
-
IoUringAdaptiveBufferRingAllocator
public IoUringAdaptiveBufferRingAllocator(ByteBufAllocator allocator, int minimum, int initial, int maximum) Creates new instance.- Parameters:
allocator- theByteBufAllocatorto use for the allocationsminimum- the inclusive lower bound of the expected buffer sizeinitial- the initial buffer size when no feed back was receivedmaximum- the inclusive upper bound of the expected buffer size
-
IoUringAdaptiveBufferRingAllocator
public IoUringAdaptiveBufferRingAllocator(ByteBufAllocator allocator, int minimum, int initial, int maximum, boolean largeAllocation) Creates new instance.- Parameters:
allocator- theByteBufAllocatorto use for the allocationsminimum- the inclusive lower bound of the expected buffer sizeinitial- the initial buffer size when no feed back was receivedmaximum- the inclusive upper bound of the expected buffer sizelargeAllocation-trueif we should do a large allocation for the whole buffer ring and then slice out the buffers orfalseif we should do one allocation per buffer.
-
-
Method Details
-
nextBufferSize
protected int nextBufferSize()Description copied from class:AbstractIoUringBufferRingAllocatorReturn the next buffer size of eachByteBufthat is put into the buffer ring.- Specified by:
nextBufferSizein classAbstractIoUringBufferRingAllocator- Returns:
- the next size.
-
lastBytesRead
public void lastBytesRead(int attempted, int actual) Description copied from class:AbstractIoUringBufferRingAllocatorDoes nothing by default, sub-classes might override this.- Specified by:
lastBytesReadin interfaceIoUringBufferRingAllocator- Overrides:
lastBytesReadin classAbstractIoUringBufferRingAllocator- Parameters:
attempted- the attempted bytes to read.actual- the number of bytes that could be read.
-