Interface Reactor

All Known Subinterfaces:
VertxReactor

public interface Reactor

A reactor defines the core threading model and more specifically it provides the main event loop used at the core of Inverno's applications.

A reactor exposes a single acceptor event loop group used to accept connection and methods to create event loop groups backed by a unique core event loop group in order to optimize thread creation and usage based on hardware and software capabilities.

Since:
1.2
Author:
Jeremy Kuhn
  • Method Details

    • eventLoop

      Optional<EventLoop> eventLoop()

      Returns the event loop associated to the current thread.

      Returns:
      an optional returning the current event loop or an empty optional if the current thread is not a reactor thread.
    • getWorkerPool

      ExecutorService getWorkerPool()

      Returns the worker pool.

      The worker pool is typically used to execute blocking task outside the I/O event loop.

      Returns:
      an executor service
    • getAcceptorEventLoopGroup

      EventLoopGroup getAcceptorEventLoopGroup()

      Returns the acceptor event loop group typically with one thread.

      This event loop group should be shared across network servers to accept connections.

      Returns:
      an acceptor event loop group
    • createIoEventLoopGroup

      EventLoopGroup createIoEventLoopGroup()

      Creates an IO event loop group with all available threads.

      Returns:
      an IO event loop group
    • createIoEventLoopGroup

      EventLoopGroup createIoEventLoopGroup(int nThreads) throws IllegalArgumentException

      Creates an IO event loop group with the specified amount of threads.

      Parameters:
      nThreads - the number of threads to allocate
      Returns:
      an IO event loop group
      Throws:
      IllegalArgumentException - if the specified number of thread exceeds the number of threads available
    • getEventLoop

      EventLoop getEventLoop()

      Returns an event loop from the core IO event loop group.

      Returns:
      an event loop
    • getCoreIoEventLoopGroupSize

      int getCoreIoEventLoopGroupSize()

      Returns the size of the core IO event loop group.

      This basically the maximum number of threads one can allocate to an IO event loop group.

      Returns:
      The number of threads allocated to the core IO event loop group