Class AbstractIoUringBufferRingAllocator
java.lang.Object
io.netty.channel.uring.AbstractIoUringBufferRingAllocator
- All Implemented Interfaces:
IoUringBufferRingAllocator
- Direct Known Subclasses:
IoUringAdaptiveBufferRingAllocator, IoUringFixedBufferRingAllocator
public abstract class AbstractIoUringBufferRingAllocator
extends Object
implements IoUringBufferRingAllocator
Base class for
IoUringBufferRingAllocator implementations which support large allocations.-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractIoUringBufferRingAllocator(ByteBufAllocator allocator, boolean largeAllocation) Creates new instance. -
Method Summary
Modifier and TypeMethodDescriptionfinal ByteBufallocate()Creates a new receive buffer to use by the buffer ring.final voidallocateBatch(Consumer<ByteBuf> consumer, int number) Fill innumofByteBufs.voidlastBytesRead(int attempted, int actual) Does nothing by default, sub-classes might override this.protected abstract intReturn the next buffer size of eachByteBufthat is put into the buffer ring.
-
Constructor Details
-
AbstractIoUringBufferRingAllocator
Creates new instance.- Parameters:
allocator- theByteBufAllocatorto use for the allocationslargeAllocation-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
-
allocateBatch
Description copied from interface:IoUringBufferRingAllocator- Specified by:
allocateBatchin interfaceIoUringBufferRingAllocator- Parameters:
consumer- theConsumerthat will consume the buffers.number- the number of buffers that are passed toConsumer.accept(Object).
-
allocate
Description copied from interface:IoUringBufferRingAllocatorCreates a new receive buffer to use by the buffer ring. The returnedByteBufmust be direct.- Specified by:
allocatein interfaceIoUringBufferRingAllocator
-
lastBytesRead
public void lastBytesRead(int attempted, int actual) Does nothing by default, sub-classes might override this.- Specified by:
lastBytesReadin interfaceIoUringBufferRingAllocator- Parameters:
attempted- the attempted bytes to read.actual- the number of bytes that could be read.
-
nextBufferSize
protected abstract int nextBufferSize()Return the next buffer size of eachByteBufthat is put into the buffer ring.- Returns:
- the next size.
-