Class SerializeReentrantCallsDirectExecutor

  • All Implemented Interfaces:
    java.util.concurrent.Executor

    class SerializeReentrantCallsDirectExecutor
    extends java.lang.Object
    implements java.util.concurrent.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 Summary

      Fields 
      Modifier and Type Field Description
      private boolean executing  
      private static java.util.logging.Logger log  
      private java.util.ArrayDeque<java.lang.Runnable> taskQueue  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void completeQueuedTasks()  
      private void enqueue​(java.lang.Runnable r)  
      void execute​(java.lang.Runnable task)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • log

        private static final java.util.logging.Logger log
      • executing

        private boolean executing
      • taskQueue

        private java.util.ArrayDeque<java.lang.Runnable> taskQueue
    • Constructor Detail

      • SerializeReentrantCallsDirectExecutor

        SerializeReentrantCallsDirectExecutor()
    • Method Detail

      • execute

        public void execute​(java.lang.Runnable task)
        Specified by:
        execute in interface java.util.concurrent.Executor
      • completeQueuedTasks

        private void completeQueuedTasks()
      • enqueue

        private void enqueue​(java.lang.Runnable r)