Package io.inversion.client
Class ApiClient.Executor
- java.lang.Object
-
- io.inversion.client.ApiClient.Executor
-
- Enclosing class:
- ApiClient
public static class ApiClient.Executor extends java.lang.ObjectAn asynchronous thread pool task runner.The number of threads in the pool will be expanded up to
threadsMaxand down tothredsMinbased on the size of of the queue. Up toqueueMaxtasks 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
threadsMaxto zero. That will ensure that tasks will always execute synchronously in the calling thread and will be completed by the timesubmitreturns.
-
-
Field Summary
Fields Modifier and Type Field Description protected intqueueMaxprotected intthreadsMaxThe thread pool will by dynamically expanded up to this max number of worker threads as the queue length grows.protected intthreadsMinThe thread pool will be dynamically contracted to this minimum number of worker threads as the queue length shrinks.
-
Constructor Summary
Constructors Constructor Description Executor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetQueueMax()intgetThreadsMax()intgetThreadsMin()java.util.concurrent.Futuresubmit(java.lang.Runnable task)java.util.concurrent.RunnableFuturesubmit(java.util.concurrent.RunnableFuture task)Putstaskinto the queue to be run unlessthreadsMaxis less than one in which case the task is immediately run synchronously in stead of asynchronously.ApiClient.ExecutorwithQueueMax(int queueMax)ApiClient.ExecutorwithThreadsMax(int threadsMax)ApiClient.ExecutorwithThreadsMin(int threadsMin)
-
-
-
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
-
-
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)
Putstaskinto the queue to be run unlessthreadsMaxis 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()
-
withThreadsMin
public ApiClient.Executor withThreadsMin(int threadsMin)
-
getThreadsMax
public int getThreadsMax()
-
withThreadsMax
public ApiClient.Executor withThreadsMax(int threadsMax)
-
getQueueMax
public int getQueueMax()
-
withQueueMax
public ApiClient.Executor withQueueMax(int queueMax)
-
-