java.lang.Object
java.util.concurrent.AbstractExecutorService
java.util.concurrent.ThreadPoolExecutor
io.helidon.common.configurable.ThreadPool
- All Implemented Interfaces:
AutoCloseable
,Executor
,ExecutorService
A
ThreadPoolExecutor
with an extensible growth policy and queue state accessors.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
ARejectedExecutionHandler
that supports pool growth by re-attempting to add the task to the queue.Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
afterExecute
(Runnable r, Throwable t) static Optional
<ThreadPool> asThreadPool
(ExecutorService executor) Returns the given executor as aThreadPool
if possible.protected void
beforeExecute
(Thread t, Runnable r) int
Returns the current number of active threads.float
Returns the average number of active threads across the life of the pool.float
Returns the average queue size.int
Returns the number of completed tasks.int
Returns the number of tasks that threw an exception.getName()
Returns the name of this pool.int
Returns the peak queue size.io.helidon.common.configurable.ThreadPool.WorkQueue
getQueue()
int
Returns the queue capacity.int
Returns the current number of tasks in the queue.int
Returns the rejection count.int
Returns the number of completed and failed tasks.boolean
Tests whether or not the number of threads can change over time.void
setMaximumPoolSize
(int maximumPoolSize) void
void
shutdown()
toString()
Methods inherited from class java.util.concurrent.ThreadPoolExecutor
allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, execute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setThreadFactory, terminated
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
Methods inherited from interface java.util.concurrent.ExecutorService
close
-
Method Details
-
asThreadPool
Returns the given executor as aThreadPool
if possible.- Parameters:
executor
- The executor.- Returns:
- The thread pool or empty if not a
ThreadPool
.
-
getName
Returns the name of this pool.- Returns:
- The name.
-
getQueueCapacity
public int getQueueCapacity()Returns the queue capacity.- Returns:
- The capacity.
-
getAverageQueueSize
public float getAverageQueueSize()Returns the average queue size.- Returns:
- The size.
-
getPeakQueueSize
public int getPeakQueueSize()Returns the peak queue size.- Returns:
- The size.
-
getCompletedTasks
public int getCompletedTasks()Returns the number of completed tasks.- Returns:
- The count.
-
getFailedTasks
public int getFailedTasks()Returns the number of tasks that threw an exception.- Returns:
- The count.
-
getTotalTasks
public int getTotalTasks()Returns the number of completed and failed tasks.- Returns:
- The count.
-
getActiveThreads
public int getActiveThreads()Returns the current number of active threads.- Returns:
- The count.
-
getAverageActiveThreads
public float getAverageActiveThreads()Returns the average number of active threads across the life of the pool.- Returns:
- The average.
-
getRejectionCount
public int getRejectionCount()Returns the rejection count.- Returns:
- The count.
-
isFixedSize
public boolean isFixedSize()Tests whether or not the number of threads can change over time.- Returns:
true
if maximum size is equal to core size.
-
getQueue
public io.helidon.common.configurable.ThreadPool.WorkQueue getQueue()- Overrides:
getQueue
in classThreadPoolExecutor
-
getQueueSize
public int getQueueSize()Returns the current number of tasks in the queue.- Returns:
- The count.
-
setRejectedExecutionHandler
- Overrides:
setRejectedExecutionHandler
in classThreadPoolExecutor
-
getRejectedExecutionHandler
- Overrides:
getRejectedExecutionHandler
in classThreadPoolExecutor
-
setMaximumPoolSize
public void setMaximumPoolSize(int maximumPoolSize) - Overrides:
setMaximumPoolSize
in classThreadPoolExecutor
-
toString
- Overrides:
toString
in classThreadPoolExecutor
-
beforeExecute
- Overrides:
beforeExecute
in classThreadPoolExecutor
-
afterExecute
- Overrides:
afterExecute
in classThreadPoolExecutor
-
shutdown
public void shutdown()- Specified by:
shutdown
in interfaceExecutorService
- Overrides:
shutdown
in classThreadPoolExecutor
-
shutdownNow
- Specified by:
shutdownNow
in interfaceExecutorService
- Overrides:
shutdownNow
in classThreadPoolExecutor
-