Class TransportFilter.QueuingExecutor

  • All Implemented Interfaces:
    java.util.concurrent.Executor, java.util.concurrent.ExecutorService
    Enclosing class:
    TransportFilter

    private static class TransportFilter.QueuingExecutor
    extends java.util.concurrent.ThreadPoolExecutor
    A thread pool executor that prefers creating new worker threads over queueing tasks until the maximum poll size has been reached, after which it will start queueing tasks.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static class  TransportFilter.QueuingExecutor.HandOffQueue
      Synchronous queue that tries to empty TransportFilter.QueuingExecutor.HandOffQueue.taskQueue before it blocks waiting for new tasks to be submitted.
      • Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor

        java.util.concurrent.ThreadPoolExecutor.AbortPolicy, java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardOldestPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardPolicy
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Queue<java.lang.Runnable> taskQueue  
      private boolean threadSafeQueue  
    • Constructor Summary

      Constructors 
      Constructor Description
      QueuingExecutor​(int corePoolSize, int maximumPoolSize, long keepAliveTime, java.util.concurrent.TimeUnit unit, java.util.Queue<java.lang.Runnable> taskQueue, boolean threadSafeQueue, java.util.concurrent.ThreadFactory threadFactory)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void execute​(java.lang.Runnable task)
      Submit a task for execution, if the maximum thread limit has been reached and all the threads are occupied, enqueue the task.
      • Methods inherited from class java.util.concurrent.ThreadPoolExecutor

        afterExecute, allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, beforeExecute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, shutdown, shutdownNow, terminated, toString
      • Methods inherited from class java.util.concurrent.AbstractExecutorService

        invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
      • Methods inherited from class java.lang.Object

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

      • taskQueue

        private final java.util.Queue<java.lang.Runnable> taskQueue
      • threadSafeQueue

        private final boolean threadSafeQueue
    • Constructor Detail

      • QueuingExecutor

        QueuingExecutor​(int corePoolSize,
                        int maximumPoolSize,
                        long keepAliveTime,
                        java.util.concurrent.TimeUnit unit,
                        java.util.Queue<java.lang.Runnable> taskQueue,
                        boolean threadSafeQueue,
                        java.util.concurrent.ThreadFactory threadFactory)
        Constructor.
        Parameters:
        threadSafeQueue - indicates if taskQueue is thread safe or not.
    • Method Detail

      • execute

        public void execute​(java.lang.Runnable task)
        Submit a task for execution, if the maximum thread limit has been reached and all the threads are occupied, enqueue the task. The task is not executed by the current thread, but by a thread from the thread pool.
        Specified by:
        execute in interface java.util.concurrent.Executor
        Overrides:
        execute in class java.util.concurrent.ThreadPoolExecutor
        Parameters:
        task - to be executed.