Class ApiClient.Executor

  • Enclosing class:
    ApiClient

    public static class ApiClient.Executor
    extends java.lang.Object
    An asynchronous thread pool task runner.

    The number of threads in the pool will be expanded up to threadsMax and down to thredsMin based on the size of of the queue. Up to queueMax tasks can occupy the queue before caller will start to be blocked having to wait for queue space to clear up.

    You can completely disable asynchronous execution by setting threadsMax to zero. That will ensure that tasks will always execute synchronously in the calling thread and will be completed by the time submit returns.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int queueMax  
      protected int threadsMax
      The thread pool will by dynamically expanded up to this max number of worker threads as the queue length grows.
      protected int threadsMin
      The thread pool will be dynamically contracted to this minimum number of worker threads as the queue length shrinks.
    • Constructor Summary

      Constructors 
      Constructor Description
      Executor()  
    • Field Detail

      • threadsMin

        protected int threadsMin
        The thread pool will be dynamically contracted to this minimum number of worker threads as the queue length shrinks.
      • threadsMax

        protected int threadsMax
        The thread pool will by dynamically expanded up to this max number of worker threads as the queue length grows.

        If this number is less than 1, then tasks will be executed synchronously in the calling thread, not asynchronously.

      • queueMax

        protected int queueMax
    • Constructor Detail

      • Executor

        public Executor()
    • Method Detail

      • submit

        public java.util.concurrent.Future submit​(java.lang.Runnable task)
      • submit

        public java.util.concurrent.RunnableFuture submit​(java.util.concurrent.RunnableFuture task)
        Puts task into the queue to be run unless threadsMax is less than one in which case the task is immediately run synchronously in stead of asynchronously.
        Parameters:
        task - the task to run
        Returns:
        the task submitted
      • getThreadsMin

        public int getThreadsMin()
      • getThreadsMax

        public int getThreadsMax()
      • getQueueMax

        public int getQueueMax()