Interface IOReactor

  • All Known Subinterfaces:
    ConnectingIOReactor, ListeningIOReactor
    All Known Implementing Classes:
    AbstractIOReactor, AbstractMultiworkerIOReactor, BaseIOReactor, DefaultConnectingIOReactor, DefaultListeningIOReactor

    public interface IOReactor
    HttpCore NIO is based on the Reactor pattern as described by Doug Lea. The purpose of I/O reactors is to react to I/O events and to dispatch event notifications to individual I/O sessions. The main idea of I/O reactor pattern is to break away from the one thread per connection model imposed by the classic blocking I/O model.

    The IOReactor interface represents an abstract object implementing the Reactor pattern.

    I/O reactors usually employ a small number of dispatch threads (often as few as one) to dispatch I/O event notifications to a much greater number (often as many as several thousands) of I/O sessions or connections. It is generally recommended to have one dispatch thread per CPU core.

    Since:
    4.0
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void execute​(IOEventDispatch eventDispatch)
      Starts the reactor and initiates the dispatch of I/O event notifications to the given IOEventDispatch.
      IOReactorStatus getStatus()
      Returns the current status of the reactor.
      void shutdown()
      Initiates shutdown of the reactor and blocks for a default period of time waiting for the reactor to terminate all active connections, to shut down itself and to release system resources it currently holds.
      void shutdown​(long waitMs)
      Initiates shutdown of the reactor and blocks approximately for the given period of time in milliseconds waiting for the reactor to terminate all active connections, to shut down itself and to release system resources it currently holds.
    • Method Detail

      • getStatus

        IOReactorStatus getStatus()
        Returns the current status of the reactor.
        Returns:
        reactor status.
      • execute

        void execute​(IOEventDispatch eventDispatch)
              throws java.io.IOException
        Starts the reactor and initiates the dispatch of I/O event notifications to the given IOEventDispatch.
        Parameters:
        eventDispatch - the I/O event dispatch.
        Throws:
        java.io.IOException - in case of an I/O error.
      • shutdown

        void shutdown​(long waitMs)
               throws java.io.IOException
        Initiates shutdown of the reactor and blocks approximately for the given period of time in milliseconds waiting for the reactor to terminate all active connections, to shut down itself and to release system resources it currently holds.
        Parameters:
        waitMs - wait time in milliseconds.
        Throws:
        java.io.IOException - in case of an I/O error.
      • shutdown

        void shutdown()
               throws java.io.IOException
        Initiates shutdown of the reactor and blocks for a default period of time waiting for the reactor to terminate all active connections, to shut down itself and to release system resources it currently holds. It is up to individual implementations to decide for how long this method can remain blocked.
        Throws:
        java.io.IOException - in case of an I/O error.