Home / Type/ IoHandler Type — netty Architecture

IoHandler Type — netty Architecture

Architecture documentation for the IoHandler type/interface in IoHandler.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  17d0c588_6cb8_b361_aac9_c69d00e6daa0["IoHandler"]
  e651deb3_003e_a5c3_7cb6_48f4647b0ba9["IoHandler.java"]
  17d0c588_6cb8_b361_aac9_c69d00e6daa0 -->|defined in| e651deb3_003e_a5c3_7cb6_48f4647b0ba9
  style 17d0c588_6cb8_b361_aac9_c69d00e6daa0 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

transport/src/main/java/io/netty/channel/IoHandler.java lines 33–85

public interface IoHandler {

    /**
     * Initialize this {@link IoHandler}.
     */
    default void initialize() { }

    /**
     * Run the IO handled by this {@link IoHandler}. The {@link IoHandlerContext} should be used
     * to ensure we not execute too long and so block the processing of other task that are
     * scheduled on the {@link ThreadAwareExecutor}. This is done by taking {@link IoHandlerContext#delayNanos(long)}
     * or {@link IoHandlerContext#deadlineNanos()} into account.
     *
     * @param  context  the {@link IoHandlerContext}.
     * @return          the number of {@link IoHandle} for which I/O was handled.
     */
    int run(IoHandlerContext context);

    /**
     * Prepare to destroy this {@link IoHandler}. This method will be called before {@link #destroy()} and may be
     * called multiple times.
     */
    default void prepareToDestroy() { }

    /**
     * Destroy the {@link IoHandler} and free all its resources. Once destroyed using the {@link IoHandler} will
     * cause undefined behaviour.
     */
    default void destroy() { }

    /**
     * Register a {@link IoHandle} for IO.
     *
     * @param handle        the {@link IoHandle} to register.
     * @throws Exception    thrown if an error happens during registration.
     */
    IoRegistration register(IoHandle handle) throws Exception;

    /**
     * Wakeup the {@link IoHandler}, which means if any operation blocks it should be unblocked and
     * return as soon as possible.
     */
    void wakeup();

    /**
     * Returns {@code true} if the given type is compatible with this {@link IoHandler} and so can be registered,
     * {@code false} otherwise.
     *
     * @param handleType the type of the {@link IoHandle}.
     * @return if compatible of not.
     */
    boolean isCompatible(Class<? extends IoHandle> handleType);
}

Frequently Asked Questions

What is the IoHandler type?
IoHandler is a type/interface in the netty codebase, defined in transport/src/main/java/io/netty/channel/IoHandler.java.
Where is IoHandler defined?
IoHandler is defined in transport/src/main/java/io/netty/channel/IoHandler.java at line 33.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free