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 for IoUringBufferRingAllocator implementations which support large allocations.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final ByteBufAllocator
     
    private final boolean
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    AbstractIoUringBufferRingAllocator(ByteBufAllocator allocator, boolean largeAllocation)
    Creates new instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    final ByteBuf
    Creates a new receive buffer to use by the buffer ring.
    final void
    allocateBatch(java.util.function.Consumer<ByteBuf> consumer, int number)
    Fill in num of ByteBufs.
    void
    lastBytesRead(int attempted, int actual)
    Does nothing by default, sub-classes might override this.
    protected abstract int
    Return the next buffer size of each ByteBuf that is put into the buffer ring.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • allocator

      private final ByteBufAllocator allocator
    • largeAllocation

      private final boolean largeAllocation
  • Constructor Details

    • AbstractIoUringBufferRingAllocator

      protected AbstractIoUringBufferRingAllocator(ByteBufAllocator allocator, boolean largeAllocation)
      Creates new instance.
      Parameters:
      allocator - the ByteBufAllocator to use for the allocations
      largeAllocation - true if we should do a large allocation for the whole buffer ring and then slice out the buffers or false if we should do one allocation per buffer.
  • Method Details

    • allocateBatch

      public final void allocateBatch(java.util.function.Consumer<ByteBuf> consumer, int number)
      Description copied from interface: IoUringBufferRingAllocator
      Fill in num of ByteBufs. Important: The Consumer MUST not escape this method.
      Specified by:
      allocateBatch in interface IoUringBufferRingAllocator
      Parameters:
      consumer - the Consumer that will consume the buffers.
      number - the number of buffers that are passed to Consumer.accept(Object).
    • allocate

      public final ByteBuf allocate()
      Description copied from interface: IoUringBufferRingAllocator
      Creates a new receive buffer to use by the buffer ring. The returned ByteBuf must be direct.
      Specified by:
      allocate in interface IoUringBufferRingAllocator
    • lastBytesRead

      public void lastBytesRead(int attempted, int actual)
      Does nothing by default, sub-classes might override this.
      Specified by:
      lastBytesRead in interface IoUringBufferRingAllocator
      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 each ByteBuf that is put into the buffer ring.
      Returns:
      the next size.