Class ImmediateEventExecutor

java.lang.Object
java.util.concurrent.AbstractExecutorService
io.netty.util.concurrent.AbstractEventExecutor
io.netty.util.concurrent.ImmediateEventExecutor
All Implemented Interfaces:
EventExecutor, EventExecutorGroup, ThreadAwareExecutor, java.lang.Iterable<EventExecutor>, java.util.concurrent.Executor, java.util.concurrent.ExecutorService, java.util.concurrent.ScheduledExecutorService

public final class ImmediateEventExecutor extends AbstractEventExecutor
Executes Runnable objects in the caller's thread. If the execute(Runnable) is reentrant it will be queued until the original Runnable finishes execution.

All Throwable objects thrown from execute(Runnable) will be swallowed and logged. This is to ensure that all queued Runnable objects have the chance to be run.

  • Field Details

    • logger

      private static final InternalLogger logger
    • INSTANCE

      public static final ImmediateEventExecutor INSTANCE
    • DELAYED_RUNNABLES

      private static final FastThreadLocal<java.util.Queue<java.lang.Runnable>> DELAYED_RUNNABLES
      A Runnable will be queued if we are executing a Runnable. This is to prevent a StackOverflowError.
    • RUNNING

      private static final FastThreadLocal<java.lang.Boolean> RUNNING
      Set to true if we are executing a runnable.
    • terminationFuture

      private final Future<?> terminationFuture
  • Constructor Details

    • ImmediateEventExecutor

      private ImmediateEventExecutor()
  • Method Details

    • inEventLoop

      public boolean inEventLoop()
      Description copied from interface: EventExecutor
      Calls EventExecutor.inEventLoop(Thread) with Thread.currentThread() as argument
    • inEventLoop

      public boolean inEventLoop(java.lang.Thread thread)
      Description copied from interface: EventExecutor
      Return true if the given Thread is executed in the event loop, false otherwise.
    • shutdownGracefully

      public Future<?> shutdownGracefully(long quietPeriod, long timeout, java.util.concurrent.TimeUnit unit)
      Description copied from interface: EventExecutorGroup
      Signals this executor that the caller wants the executor to be shut down. Once this method is called, EventExecutorGroup.isShuttingDown() starts to return true, and the executor prepares to shut itself down. Unlike EventExecutorGroup.shutdown(), graceful shutdown ensures that no tasks are submitted for 'the quiet period' (usually a couple seconds) before it shuts itself down. If a task is submitted during the quiet period, it is guaranteed to be accepted and the quiet period will start over.
      Parameters:
      quietPeriod - the quiet period as described in the documentation
      timeout - the maximum amount of time to wait until the executor is EventExecutorGroup.shutdown() regardless if a task was submitted during the quiet period
      unit - the unit of quietPeriod and timeout
      Returns:
      the EventExecutorGroup.terminationFuture()
    • terminationFuture

      public Future<?> terminationFuture()
      Description copied from interface: EventExecutorGroup
      Returns the Future which is notified when all EventExecutors managed by this EventExecutorGroup have been terminated.
    • shutdown

      @Deprecated public void shutdown()
      Deprecated.
      Specified by:
      shutdown in interface EventExecutorGroup
      Specified by:
      shutdown in interface java.util.concurrent.ExecutorService
      Specified by:
      shutdown in class AbstractEventExecutor
    • isShuttingDown

      public boolean isShuttingDown()
      Description copied from interface: EventExecutorGroup
      Returns true if and only if all EventExecutors managed by this EventExecutorGroup are being shut down gracefully or was shut down.
    • isShutdown

      public boolean isShutdown()
    • isTerminated

      public boolean isTerminated()
    • awaitTermination

      public boolean awaitTermination(long timeout, java.util.concurrent.TimeUnit unit)
    • execute

      public void execute(java.lang.Runnable command)
    • newPromise

      public <V> Promise<V> newPromise()
      Description copied from interface: EventExecutor
      Return a new Promise.
    • newProgressivePromise

      public <V> ProgressivePromise<V> newProgressivePromise()
      Description copied from interface: EventExecutor
      Create a new ProgressivePromise.