Class SingleThreadIoEventLoop

All Implemented Interfaces:
EventLoop, EventLoopGroup, IoEventLoop, IoEventLoopGroup, EventExecutor, EventExecutorGroup, OrderedEventExecutor, ThreadAwareExecutor, java.lang.Iterable<EventExecutor>, java.util.concurrent.Executor, java.util.concurrent.ExecutorService, java.util.concurrent.ScheduledExecutorService
Direct Known Subclasses:
EpollEventLoop, KQueueEventLoopGroup.KQueueEventLoop, NioEventLoop

public class SingleThreadIoEventLoop extends SingleThreadEventLoop implements IoEventLoop
IoEventLoop implementation that execute all its submitted tasks in a single thread using the provided IoHandler.
  • Field Details

    • DEFAULT_MAX_TASK_PROCESSING_QUANTUM_NS

      private static final long DEFAULT_MAX_TASK_PROCESSING_QUANTUM_NS
    • DEFAULT_IO_RATIO

      static final int DEFAULT_IO_RATIO
    • maxTaskProcessingQuantumNs

      private final long maxTaskProcessingQuantumNs
    • ioRatio

      private volatile int ioRatio
    • activeIoTimeNanos

      private long activeIoTimeNanos
    • context

      private final IoHandlerContext context
    • ioHandler

      private final IoHandler ioHandler
    • numRegistrations

      private final java.util.concurrent.atomic.AtomicInteger numRegistrations
  • Constructor Details

    • SingleThreadIoEventLoop

      public SingleThreadIoEventLoop(IoEventLoopGroup parent, java.util.concurrent.ThreadFactory threadFactory, IoHandlerFactory ioHandlerFactory)
      Creates a new instance
      Parameters:
      parent - the parent that holds this IoEventLoop.
      threadFactory - the ThreadFactory that is used to create the underlying Thread.
      ioHandlerFactory - the IoHandlerFactory that should be used to obtain IoHandler to handle IO.
    • SingleThreadIoEventLoop

      public SingleThreadIoEventLoop(IoEventLoopGroup parent, java.util.concurrent.Executor executor, IoHandlerFactory ioHandlerFactory)
      Creates a new instance
      Parameters:
      parent - the parent that holds this IoEventLoop.
      executor - the Executor that is used for dispatching the work.
      ioHandlerFactory - the IoHandlerFactory that should be used to obtain IoHandler to handle IO.
    • SingleThreadIoEventLoop

      public SingleThreadIoEventLoop(IoEventLoopGroup parent, java.util.concurrent.ThreadFactory threadFactory, IoHandlerFactory ioHandlerFactory, int maxPendingTasks, RejectedExecutionHandler rejectedExecutionHandler, long maxTaskProcessingQuantumMs)
      Creates a new instance
      Parameters:
      parent - the parent that holds this IoEventLoop.
      threadFactory - the ThreadFactory that is used to create the underlying Thread.
      ioHandlerFactory - the IoHandlerFactory that should be used to obtain IoHandler to handle IO.
      maxPendingTasks - the maximum pending tasks that are allowed before RejectedExecutionHandler.rejected(Runnable, SingleThreadEventExecutor) is called to handle it.
      rejectedExecutionHandler - the RejectedExecutionHandler that handles when more tasks are added then allowed per maxPendingTasks.
      maxTaskProcessingQuantumMs - the maximum number of milliseconds that will be spent to run tasks before trying to run IO again.
    • SingleThreadIoEventLoop

      public SingleThreadIoEventLoop(IoEventLoopGroup parent, java.util.concurrent.Executor executor, IoHandlerFactory ioHandlerFactory, int maxPendingTasks, RejectedExecutionHandler rejectedExecutionHandler, long maxTaskProcessingQuantumMs)
      Creates a new instance
      Parameters:
      parent - the parent that holds this IoEventLoop.
      ioHandlerFactory - the IoHandlerFactory that should be used to obtain IoHandler to handle IO.
      maxPendingTasks - the maximum pending tasks that are allowed before RejectedExecutionHandler.rejected(Runnable, SingleThreadEventExecutor) is called to handle it.
      rejectedExecutionHandler - the RejectedExecutionHandler that handles when more tasks are added then allowed per maxPendingTasks.
      maxTaskProcessingQuantumMs - the maximum number of milliseconds that will be spent to run tasks before trying to run IO again.
    • SingleThreadIoEventLoop

      protected SingleThreadIoEventLoop(IoEventLoopGroup parent, java.util.concurrent.Executor executor, IoHandlerFactory ioHandlerFactory, java.util.Queue<java.lang.Runnable> taskQueue, java.util.Queue<java.lang.Runnable> tailTaskQueue, RejectedExecutionHandler rejectedExecutionHandler)
      Creates a new instance
      Parameters:
      parent - the parent that holds this IoEventLoop.
      executor - the Executor that is used for dispatching the work.
      ioHandlerFactory - the IoHandlerFactory that should be used to obtain IoHandler to handle IO.
      taskQueue - the Queue used for storing pending tasks.
      tailTaskQueue - the Queue used for storing tail pending tasks.
      rejectedExecutionHandler - the RejectedExecutionHandler that handles when more tasks are added then allowed.
  • Method Details