Class IoUringIoHandler
java.lang.Object
io.netty.channel.uring.IoUringIoHandler
- All Implemented Interfaces:
IoHandler
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate final class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate final FileDescriptorprivate static final longprivate final AtomicBooleanprivate booleanprivate final ByteBufferprivate final longprivate final CleanableDirectBufferprivate longprivate final ThreadAwareExecutorprivate final byte[]private final byte[]private static final longprivate final IovArrayprivate final IovArrayReferenceCollectorprivate static final intprivate static final intprivate static final intprivate static final InternalLoggerprivate final MsgHdrMemoryArrayprivate intprivate final PendingOpMapprivate final IntObjectMap<IoUringBufferRing> private final IntObjectMap<IoUringIoHandler.DefaultIoUringIoRegistration> private final RingBufferprivate static final longprivate booleanprivate final ByteBufferprivate final longprivate final CleanableDirectBufferprivate static final intprivate final AtomicInteger -
Constructor Summary
ConstructorsConstructorDescriptionIoUringIoHandler(ThreadAwareExecutor executor, IoUringIoHandlerConfig config) -
Method Summary
Modifier and TypeMethodDescriptionprivate static IoUringIoHandleprivate voidprivate voidvoiddestroy()Destroy theIoHandlerand free all its resources.private void(package private) IoUringBufferRingfindBufferRing(short bgId) private booleanhandle(int res, int flags, long udata, ByteBuffer extraCqeData) private voidprivate voidhandleFastPath(int res, int flags, long udata, ByteBuffer extraCqeData) private static voidhandleLoopException(Throwable throwable) private voidhandleSlowPath(int res, int flags, long udata, ByteBuffer extraCqeData) (package private) byte[]byte[]that can be used as temporary storage to encode the ipv4 address(package private) byte[]byte[]that can be used as temporary storage to encode the ipv6 addressvoidInitialize thisIoHandler.(package private) IovArrayiovArray()(package private) IovArrayReferenceCollectorReturns theIovArrayReferenceCollectorpaired withiovArray().booleanisCompatible(Class<? extends IoHandle> handleType) Returnstrueif the given type is compatible with thisIoHandlerand so can be registered,falseotherwise.(package private) MsgHdrMemoryArrayprivate booleanneedSubmit(int sqFlags) private static IoUringBufferRingnewBufferRing(int ringFd, IoUringBufferRingConfig bufferRingConfig) static IoHandlerFactoryCreate a newIoHandlerFactorythat can be used to createIoUringIoHandlers.static IoHandlerFactorynewFactory(int ringSize) Create a newIoHandlerFactorythat can be used to createIoUringIoHandlers.static IoHandlerFactorynewFactory(IoUringIoHandlerConfig config) Create a newIoHandlerFactorythat can be used to createIoUringIoHandlers.private intvoidPrepare to destroy thisIoHandler.private intprocessCompletionsAndHandleOverflow(SubmissionQueue submissionQueue, CompletionQueue completionQueue, CompletionCallback callback) Register aIoHandlefor IO.intrun(IoHandlerContext context) Run the IO handled by thisIoHandler.private intsubmitAndClearNow(SubmissionQueue submissionQueue) private intsubmitAndClearNow0(SubmissionQueue submissionQueue) private intsubmitAndWaitWithTimeout(SubmissionQueue submissionQueue, boolean linkTimeout, long timeoutNanoSeconds) private void(package private) intprivate voidtraceCompletion(IoUringIoHandler.DefaultIoUringIoRegistration registration, int registrationId, byte op, int res) voidwakeup()Wakeup theIoHandler, which means if any operation blocks it should be unblocked and return as soon as possible.
-
Field Details
-
logger
-
WAKEUP_CLOSED
private static final int WAKEUP_CLOSED- See Also:
-
ringBuffer
-
registeredIoUringBufferRing
-
registrations
-
inet4AddressArray
private final byte[] inet4AddressArray -
inet6AddressArray
private final byte[] inet6AddressArray -
eventfdAsyncNotify
-
wakeupWriters
-
eventfd
-
eventfdReadBufCleanable
-
eventfdReadBuf
-
eventfdReadBufAddress
private final long eventfdReadBufAddress -
timeoutMemoryCleanable
-
timeoutMemory
-
timeoutMemoryAddress
private final long timeoutMemoryAddress -
iovArray
-
iovArrayReferenceCollector
-
msgHdrMemoryArray
-
eventfdReadSubmitted
private long eventfdReadSubmitted -
eventFdClosing
private boolean eventFdClosing -
shuttingDown
private volatile boolean shuttingDown -
closeCompleted
private boolean closeCompleted -
pendingOps
-
nextRegistrationId
private int nextRegistrationId -
INVALID_ID
private static final long INVALID_ID- See Also:
-
EVENTFD_TOKEN
private static final long EVENTFD_TOKEN -
RINGFD_TOKEN
private static final long RINGFD_TOKEN -
KERNEL_TIMESPEC_SIZE
private static final int KERNEL_TIMESPEC_SIZE- See Also:
-
KERNEL_TIMESPEC_TV_SEC_FIELD
private static final int KERNEL_TIMESPEC_TV_SEC_FIELD- See Also:
-
KERNEL_TIMESPEC_TV_NSEC_FIELD
private static final int KERNEL_TIMESPEC_TV_NSEC_FIELD- See Also:
-
executor
-
-
Constructor Details
-
IoUringIoHandler
IoUringIoHandler(ThreadAwareExecutor executor, IoUringIoHandlerConfig config)
-
-
Method Details
-
initialize
public void initialize()Description copied from interface:IoHandlerInitialize thisIoHandler.- Specified by:
initializein interfaceIoHandler
-
run
Description copied from interface:IoHandlerRun the IO handled by thisIoHandler. TheIoHandlerContextshould be used to ensure we not execute too long and so block the processing of other task that are scheduled on theThreadAwareExecutor. This is done by takingIoHandlerContext.delayNanos(long)orIoHandlerContext.deadlineNanos()into account.- Specified by:
runin interfaceIoHandler- Parameters:
context- theIoHandlerContext.- Returns:
- the number of
IoHandlefor which I/O was handled. Internal events such as wakeups and timer expirations must not be included in this count.
-
submitIfFullAndGetRemaining
int submitIfFullAndGetRemaining() -
needSubmit
private boolean needSubmit(int sqFlags) -
processCompletionsAndHandleOverflow
private int processCompletionsAndHandleOverflow(SubmissionQueue submissionQueue, CompletionQueue completionQueue, CompletionCallback callback) -
submitAndClearNow
-
submitAndClearNow0
-
newBufferRing
private static IoUringBufferRing newBufferRing(int ringFd, IoUringBufferRingConfig bufferRingConfig) throws Errors.NativeIoException - Throws:
Errors.NativeIoException
-
findBufferRing
-
handleLoopException
-
handle
-
handleFastPath
-
handleSlowPath
-
traceCompletion
private void traceCompletion(IoUringIoHandler.DefaultIoUringIoRegistration registration, int registrationId, byte op, int res) -
handleEventFdRead
private void handleEventFdRead() -
submitEventFdRead
private void submitEventFdRead() -
submitAndWaitWithTimeout
private int submitAndWaitWithTimeout(SubmissionQueue submissionQueue, boolean linkTimeout, long timeoutNanoSeconds) -
prepareToDestroy
public void prepareToDestroy()Description copied from interface:IoHandlerPrepare to destroy thisIoHandler. This method will be called beforeIoHandler.destroy()and may be called multiple times.- Specified by:
prepareToDestroyin interfaceIoHandler
-
destroy
-
drainEventFd
private void drainEventFd() -
completeRingClose
private void completeRingClose() -
register
-
nextRegistrationId
private int nextRegistrationId() -
cast
-
wakeup
-
closeWakeupGate
private void closeWakeupGate() -
isCompatible
Description copied from interface:IoHandlerReturnstrueif the given type is compatible with thisIoHandlerand so can be registered,falseotherwise.- Specified by:
isCompatiblein interfaceIoHandler- Parameters:
handleType- the type of theIoHandle.- Returns:
- if compatible of not.
-
iovArray
IovArray iovArray() -
iovArrayReferenceCollector
IovArrayReferenceCollector iovArrayReferenceCollector()Returns theIovArrayReferenceCollectorpaired withiovArray(). A plain getter: callers are expected to have already callediovArray()to make room, so this must not itself submit-and-clear. -
msgHdrMemoryArray
MsgHdrMemoryArray msgHdrMemoryArray() -
inet4AddressArray
byte[] inet4AddressArray()byte[]that can be used as temporary storage to encode the ipv4 address -
inet6AddressArray
byte[] inet6AddressArray()byte[]that can be used as temporary storage to encode the ipv6 address -
newFactory
Create a newIoHandlerFactorythat can be used to createIoUringIoHandlers.- Returns:
- factory
-
newFactory
Create a newIoHandlerFactorythat can be used to createIoUringIoHandlers. EachIoUringIoHandlerwill use a ring of sizeringSize.- Parameters:
ringSize- the size of the ring.- Returns:
- factory
-
newFactory
Create a newIoHandlerFactorythat can be used to createIoUringIoHandlers. EachIoUringIoHandlerwill use same option- Parameters:
config- the io_uring configuration- Returns:
- factory
-