Class IoUringBufferRing


  • final class IoUringBufferRing
    extends java.lang.Object
    • Field Detail

      • SHORT_HANDLE

        private static final VarHandle SHORT_HANDLE
      • ioUringBufRing

        private final java.nio.ByteBuffer ioUringBufRing
      • tailFieldPosition

        private final int tailFieldPosition
      • entries

        private final short entries
      • mask

        private final short mask
      • bufferGroupId

        private final short bufferGroupId
      • ringFd

        private final int ringFd
      • buffers

        private final ByteBuf[] buffers
      • batchAllocation

        private final boolean batchAllocation
      • incremental

        private final boolean incremental
      • batchSize

        private final int batchSize
      • corrupted

        private boolean corrupted
      • closed

        private boolean closed
      • usableBuffers

        private int usableBuffers
      • allocatedBuffers

        private int allocatedBuffers
      • needExpand

        private boolean needExpand
      • lastGeneratedBid

        private short lastGeneratedBid
    • Constructor Detail

      • IoUringBufferRing

        IoUringBufferRing​(int ringFd,
                          java.nio.ByteBuffer ioUringBufRing,
                          short entries,
                          int batchSize,
                          short bufferGroupId,
                          boolean incremental,
                          IoUringBufferRingAllocator allocator,
                          boolean batchAllocation)
    • Method Detail

      • isUsable

        boolean isUsable()
      • initialize

        void initialize()
      • expand

        boolean expand()
        Try to expand by adding more buffers to the ring if there is any space left, this will be done lazy.
        Returns:
        true if we can expand the number of buffers in the ring, false otherwise.
      • fill

        private void fill​(short startBid,
                          int buffers)
      • fill

        private void fill​(short bid)
      • attemptedBytesRead

        int attemptedBytesRead​(short bid)
        Return the amount of bytes that we attempted to read for the given id. This method must be called before useBuffer(short, int, boolean).
        Parameters:
        bid - the id of the buffer.
        Returns:
        the attempted bytes.
      • calculateNextBufferBatch

        private int calculateNextBufferBatch()
      • useBuffer

        ByteBuf useBuffer​(short bid,
                          int read,
                          boolean more)
        Use the buffer for the given buffer id. The returned ByteBuf must be released once not used anymore.
        Parameters:
        bid - the id of the buffer
        read - the number of bytes that could be read. This value might be larger then what a single ByteBuf can hold. Because of this, the caller should call
      • nextBid

        short nextBid​(short bid)
      • bufferGroupId

        short bufferGroupId()
        The group id that is assigned to this buffer ring.
        Returns:
        group id.
      • close

        void close()
        Close this IoUringBufferRing, using it after this method is called will lead to undefined behaviour.