Package io.netty.channel.uring
Class IoUringAdaptiveBufferRingAllocator
- java.lang.Object
-
- io.netty.channel.uring.AbstractIoUringBufferRingAllocator
-
- io.netty.channel.uring.IoUringAdaptiveBufferRingAllocator
-
- All Implemented Interfaces:
IoUringBufferRingAllocator
public final class IoUringAdaptiveBufferRingAllocator extends AbstractIoUringBufferRingAllocator
IoUringBufferRingAllocatorimplementation 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
Fields Modifier and Type Field Description static intDEFAULT_INITIALstatic intDEFAULT_MAXIMUMstatic intDEFAULT_MINIMUM
-
Constructor Summary
Constructors Constructor Description IoUringAdaptiveBufferRingAllocator()IoUringAdaptiveBufferRingAllocator(ByteBufAllocator allocator)Creates 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidlastBytesRead(int attempted, int actual)Does nothing by default, sub-classes might override this.protected intnextBufferSize()Return the next buffer size of eachByteBufthat is put into the buffer ring.-
Methods inherited from class io.netty.channel.uring.AbstractIoUringBufferRingAllocator
allocate, allocateBatch
-
-
-
-
Field Detail
-
DEFAULT_MINIMUM
public static final int DEFAULT_MINIMUM
- See Also:
- Constant Field Values
-
DEFAULT_INITIAL
public static final int DEFAULT_INITIAL
- See Also:
- Constant Field Values
-
DEFAULT_MAXIMUM
public static final int DEFAULT_MAXIMUM
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
IoUringAdaptiveBufferRingAllocator
public IoUringAdaptiveBufferRingAllocator()
-
IoUringAdaptiveBufferRingAllocator
public IoUringAdaptiveBufferRingAllocator(ByteBufAllocator allocator)
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 Detail
-
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.
-
-