Package io.netty.channel.uring
Class AbstractIoUringBufferRingAllocator
- java.lang.Object
-
- io.netty.channel.uring.AbstractIoUringBufferRingAllocator
-
- All Implemented Interfaces:
IoUringBufferRingAllocator
- Direct Known Subclasses:
IoUringAdaptiveBufferRingAllocator
,IoUringFixedBufferRingAllocator
public abstract class AbstractIoUringBufferRingAllocator extends java.lang.Object implements IoUringBufferRingAllocator
Base class forIoUringBufferRingAllocator
implementations which support large allocations.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractIoUringBufferRingAllocator(ByteBufAllocator allocator, boolean largeAllocation)
Creates new instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description ByteBuf
allocate()
Creates a new receive buffer to use by the buffer ring.void
allocateBatch(java.util.function.Consumer<ByteBuf> consumer, int number)
Fill innum
ofByteBuf
s.void
lastBytesRead(int attempted, int actual)
Does nothing by default, sub-classes might override this.protected abstract int
nextBufferSize()
Return the next buffer size of eachByteBuf
that is put into the buffer ring.
-
-
-
Constructor Detail
-
AbstractIoUringBufferRingAllocator
protected AbstractIoUringBufferRingAllocator(ByteBufAllocator allocator, boolean largeAllocation)
Creates new instance.- Parameters:
allocator
- theByteBufAllocator
to use for the allocationslargeAllocation
-true
if we should do a large allocation for the whole buffer ring and then slice out the buffers orfalse
if we should do one allocation per buffer.
-
-
Method Detail
-
allocateBatch
public final void allocateBatch(java.util.function.Consumer<ByteBuf> consumer, int number)
Description copied from interface:IoUringBufferRingAllocator
- Specified by:
allocateBatch
in interfaceIoUringBufferRingAllocator
- Parameters:
consumer
- theConsumer
that will consume the buffers.number
- the number of buffers that are passed toConsumer.accept(Object)
.
-
allocate
public final ByteBuf allocate()
Description copied from interface:IoUringBufferRingAllocator
Creates a new receive buffer to use by the buffer ring. The returnedByteBuf
must be direct.- Specified by:
allocate
in interfaceIoUringBufferRingAllocator
-
lastBytesRead
public void lastBytesRead(int attempted, int actual)
Does nothing by default, sub-classes might override this.- Specified by:
lastBytesRead
in 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 eachByteBuf
that is put into the buffer ring.- Returns:
- the next size.
-
-