Package io.netty.channel
Interface IoHandler
-
- All Known Implementing Classes:
EpollIoHandler
,IoUringIoHandler
,KQueueIoHandler
,LocalIoHandler
,NioIoHandler
public interface IoHandler
Handles IO dispatching for anThreadAwareExecutor
. All operations exceptwakeup()
andisCompatible(Class)
MUST be executed on theThreadAwareExecutor
thread (which meansThreadAwareExecutor.isExecutorThread(Thread)
must returntrue
) and should never be called from the user-directly.Once a
IoHandle
is registered via theregister(IoHandle)
method it's possible to submitIoOps
related to theIoHandle
viaIoRegistration.submit(IoOps)
. These submittedIoOps
are the "source" ofIoEvent
s that are dispatched to the registeredIoHandle
via 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 void
destroy()
Destroy theIoHandler
and free all its resources.default void
initialize()
Initialize thisIoHandler
.boolean
isCompatible(java.lang.Class<? extends IoHandle> handleType)
Returnstrue
if the given type is compatible with thisIoHandler
and so can be registered,false
otherwise.default void
prepareToDestroy()
Prepare to destroy thisIoHandler
.IoRegistration
register(IoHandle handle)
Register aIoHandle
for IO.int
run(IoHandlerContext context)
Run the IO handled by thisIoHandler
.void
wakeup()
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
. TheIoHandlerContext
should 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
IoHandle
for which I/O was handled.
-
prepareToDestroy
default void prepareToDestroy()
-
destroy
default void destroy()
-
register
IoRegistration register(IoHandle handle) throws java.lang.Exception
Register aIoHandle
for IO.- Parameters:
handle
- theIoHandle
to 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.
-
-