AbstractIoUringBufferRingAllocator Class — netty Architecture
Architecture documentation for the AbstractIoUringBufferRingAllocator class in AbstractIoUringBufferRingAllocator.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 4b72e18f_c8bb_55ea_6af6_ff5a52f918ae["AbstractIoUringBufferRingAllocator"] 2c754f87_5955_e14a_3054_ec02084fd01e["AbstractIoUringBufferRingAllocator.java"] 4b72e18f_c8bb_55ea_6af6_ff5a52f918ae -->|defined in| 2c754f87_5955_e14a_3054_ec02084fd01e fda146b8_8b59_554c_6a7e_a392e86261a8["AbstractIoUringBufferRingAllocator()"] 4b72e18f_c8bb_55ea_6af6_ff5a52f918ae -->|method| fda146b8_8b59_554c_6a7e_a392e86261a8 e61e35bc_2419_fc59_2447_f13c45617c96["allocateBatch()"] 4b72e18f_c8bb_55ea_6af6_ff5a52f918ae -->|method| e61e35bc_2419_fc59_2447_f13c45617c96 3cf9ed25_e771_cc72_cc1c_a50a0dcf664e["ByteBuf()"] 4b72e18f_c8bb_55ea_6af6_ff5a52f918ae -->|method| 3cf9ed25_e771_cc72_cc1c_a50a0dcf664e b098776b_8411_d884_2c2f_eb51b9434e08["lastBytesRead()"] 4b72e18f_c8bb_55ea_6af6_ff5a52f918ae -->|method| b098776b_8411_d884_2c2f_eb51b9434e08 8a1b80ab_8d8f_467f_69b5_0c29207c484b["nextBufferSize()"] 4b72e18f_c8bb_55ea_6af6_ff5a52f918ae -->|method| 8a1b80ab_8d8f_467f_69b5_0c29207c484b
Relationship Graph
Source Code
transport-classes-io_uring/src/main/java/io/netty/channel/uring/AbstractIoUringBufferRingAllocator.java lines 27–86
public abstract class AbstractIoUringBufferRingAllocator implements IoUringBufferRingAllocator {
private final ByteBufAllocator allocator;
private final boolean largeAllocation;
/**
* Creates new instance.
*
* @param allocator the {@link ByteBufAllocator} to use for the allocations
* @param largeAllocation {@code true} if we should do a large allocation for the whole buffer ring
* and then slice out the buffers or {@code false} if we should do one allocation
* per buffer.
*/
protected AbstractIoUringBufferRingAllocator(ByteBufAllocator allocator, boolean largeAllocation) {
this.allocator = Objects.requireNonNull(allocator, "allocator");
this.largeAllocation = largeAllocation;
}
@Override
public final void allocateBatch(Consumer<ByteBuf> consumer, int number) {
if (largeAllocation) {
int bufferSize = nextBufferSize();
ByteBuf buffer = allocator.directBuffer(nextBufferSize() * number);
try {
for (int i = 0; i < number; i++) {
consumer.accept(buffer
.retainedSlice(i * bufferSize, bufferSize)
.setIndex(0, 0)
);
}
} finally {
buffer.release();
}
} else {
IoUringBufferRingAllocator.super.allocateBatch(consumer, number);
}
}
@Override
public final ByteBuf allocate() {
return allocator.directBuffer(nextBufferSize());
}
/**
* Does nothing by default, sub-classes might override this.
*
* @param attempted the attempted bytes to read.
* @param actual the number of bytes that could be read.
*/
@Override
public void lastBytesRead(int attempted, int actual) {
// NOOP.
}
/**
* Return the next buffer size of each {@link ByteBuf} that is put into the buffer ring.
*
* @return the next size.
*/
protected abstract int nextBufferSize();
}
Source
Frequently Asked Questions
What is the AbstractIoUringBufferRingAllocator class?
AbstractIoUringBufferRingAllocator is a class in the netty codebase, defined in transport-classes-io_uring/src/main/java/io/netty/channel/uring/AbstractIoUringBufferRingAllocator.java.
Where is AbstractIoUringBufferRingAllocator defined?
AbstractIoUringBufferRingAllocator is defined in transport-classes-io_uring/src/main/java/io/netty/channel/uring/AbstractIoUringBufferRingAllocator.java at line 27.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free