Class SerializeReentrantCallsDirectExecutor

java.lang.Object
io.grpc.internal.SerializeReentrantCallsDirectExecutor
All Implemented Interfaces:
Executor

class SerializeReentrantCallsDirectExecutor extends Object implements Executor
Executes a task directly in the calling thread, unless it's a reentrant call in which case the task is enqueued and executed once the calling task completes.

The Executor assumes that reentrant calls are rare and its fast path is thus optimized for that - avoiding queuing and additional object creation altogether.

This class is not thread-safe.

  • Field Details

    • log

      private static final Logger log
    • executing

      private boolean executing
    • taskQueue

      private ArrayDeque<Runnable> taskQueue
  • Constructor Details

    • SerializeReentrantCallsDirectExecutor

      SerializeReentrantCallsDirectExecutor()
  • Method Details

    • execute

      public void execute(Runnable task)
      Specified by:
      execute in interface Executor
    • completeQueuedTasks

      private void completeQueuedTasks()
    • enqueue

      private void enqueue(Runnable r)