Package io.netty.channel
Interface IoHandler
-
- All Known Implementing Classes:
EpollIoHandler,IoUringIoHandler,KQueueIoHandler,LocalIoHandler,NioIoHandler
public interface IoHandlerHandles IO dispatching for anThreadAwareExecutor. All operations exceptwakeup()andisCompatible(Class)MUST be executed on theThreadAwareExecutorthread (which meansThreadAwareExecutor.isExecutorThread(Thread)must returntrue) and should never be called from the user-directly.Once a
IoHandleis registered via theregister(IoHandle)method it's possible to submitIoOpsrelated to theIoHandleviaIoRegistration.submit(IoOps). These submittedIoOpsare the "source" ofIoEvents that are dispatched to the registeredIoHandlevia theIoHandle.handle(IoRegistration, IoEvent)method. These events must be consumed (and handled) as otherwise they might be reported again until handled.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default voiddestroy()Destroy theIoHandlerand free all its resources.default voidinitialize()Initialize thisIoHandler.booleanisCompatible(java.lang.Class<? extends IoHandle> handleType)Returnstrueif the given type is compatible with thisIoHandlerand so can be registered,falseotherwise.default voidprepareToDestroy()Prepare to destroy thisIoHandler.IoRegistrationregister(IoHandle handle)Register aIoHandlefor IO.intrun(IoHandlerContext context)Run the IO handled by thisIoHandler.voidwakeup()Wakeup theIoHandler, which means if any operation blocks it should be unblocked and return as soon as possible.
-
-
-
Method Detail
-
initialize
default void initialize()
Initialize thisIoHandler.
-
run
int run(IoHandlerContext context)
Run 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.- Parameters:
context- theIoHandlerContext.- Returns:
- the number of
IoHandlefor which I/O was handled.
-
prepareToDestroy
default void prepareToDestroy()
-
destroy
default void destroy()
-
register
IoRegistration register(IoHandle handle) throws java.lang.Exception
Register aIoHandlefor IO.- Parameters:
handle- theIoHandleto register.- Throws:
java.lang.Exception- thrown if an error happens during registration.
-
wakeup
void wakeup()
Wakeup theIoHandler, which means if any operation blocks it should be unblocked and return as soon as possible.
-
-