Interface IoHandler
- All Known Implementing Classes:
EpollIoHandler, IoUringIoHandler, KQueueIoHandler, LocalIoHandler, NioIoHandler
public interface IoHandler
Handles IO dispatching for an
ThreadAwareExecutor.
All operations except wakeup() and isCompatible(Class) MUST be executed
on the ThreadAwareExecutor thread (which means ThreadAwareExecutor.isExecutorThread(Thread) must
return true) and should never be called from the user-directly.
Once a IoHandle is registered via the register(IoHandle) method it's possible
to submit IoOps related to the IoHandle via IoRegistration.submit(IoOps).
These submitted IoOps are the "source" of IoEvents that are dispatched to the registered
IoHandle via the IoHandle.handle(IoRegistration, IoEvent) method.
These events must be consumed (and handled) as otherwise they might be reported again until handled.
-
Method Summary
Modifier and TypeMethodDescriptiondefault voiddestroy()Destroy theIoHandlerand free all its resources.default voidInitialize thisIoHandler.booleanisCompatible(Class<? extends IoHandle> handleType) Returnstrueif the given type is compatible with thisIoHandlerand so can be registered,falseotherwise.default voidPrepare to destroy thisIoHandler.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 Details
-
initialize
default void initialize()Initialize thisIoHandler. -
run
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
-
destroy
-
register
-
wakeup
void wakeup()Wakeup theIoHandler, which means if any operation blocks it should be unblocked and return as soon as possible. -
isCompatible
-