Package pl.morgwai.base.utils.concurrent
Class ScheduledTaskTrackingThreadPoolExecutor
- java.lang.Object
-
- java.util.concurrent.AbstractExecutorService
-
- java.util.concurrent.ThreadPoolExecutor
-
- java.util.concurrent.ScheduledThreadPoolExecutor
-
- pl.morgwai.base.utils.concurrent.ScheduledTaskTrackingThreadPoolExecutor
-
- All Implemented Interfaces:
Executor,ExecutorService,ScheduledExecutorService,TaskTrackingExecutor
public class ScheduledTaskTrackingThreadPoolExecutor extends ScheduledThreadPoolExecutor implements TaskTrackingExecutor
AScheduledThreadPoolExecutorthat is also aTaskTrackingExecutor. Decorates scheduled items withScheduledTaskTrackingThreadPoolExecutor.ScheduledExecution, so that the original task can be obtained.NOTE: due to the design of
task decorating in ScheduledThreadPoolExecutorthis class is extremely slow in case of a large number of very tiny tasks. See the comment with an explanation in the source.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classScheduledTaskTrackingThreadPoolExecutor.ScheduledExecution<V>Decorates aRunnableScheduledFutureto allow to obtain the original scheduled task.-
Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy
-
Nested classes/interfaces inherited from interface pl.morgwai.base.utils.concurrent.TaskTrackingExecutor
TaskTrackingExecutor.ForcedTerminationAftermath, TaskTrackingExecutor.TaskTrackingExecutorDecorator
-
-
Constructor Summary
Constructors Constructor Description ScheduledTaskTrackingThreadPoolExecutor(int corePoolSize)ScheduledTaskTrackingThreadPoolExecutor(int corePoolSize, RejectedExecutionHandler handler)ScheduledTaskTrackingThreadPoolExecutor(int corePoolSize, ThreadFactory threadFactory)ScheduledTaskTrackingThreadPoolExecutor(int corePoolSize, ThreadFactory threadFactory, RejectedExecutionHandler handler)
-
Method Summary
-
Methods inherited from class java.util.concurrent.ScheduledThreadPoolExecutor
execute, getContinueExistingPeriodicTasksAfterShutdownPolicy, getExecuteExistingDelayedTasksAfterShutdownPolicy, getQueue, getRemoveOnCancelPolicy, schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelay, setContinueExistingPeriodicTasksAfterShutdownPolicy, setExecuteExistingDelayedTasksAfterShutdownPolicy, setRemoveOnCancelPolicy, shutdown, shutdownNow, submit, submit, submit
-
Methods inherited from class java.util.concurrent.ThreadPoolExecutor
allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, terminated, toString
-
Methods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.concurrent.ExecutorService
awaitTermination, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isTerminated, shutdown, shutdownNow, submit, submit, submit
-
Methods inherited from interface pl.morgwai.base.utils.concurrent.TaskTrackingExecutor
awaitTermination, toAwaitableOfEnforcedTermination, toAwaitableOfTermination
-
-
-
-
Constructor Detail
-
ScheduledTaskTrackingThreadPoolExecutor
public ScheduledTaskTrackingThreadPoolExecutor(int corePoolSize)
-
ScheduledTaskTrackingThreadPoolExecutor
public ScheduledTaskTrackingThreadPoolExecutor(int corePoolSize, ThreadFactory threadFactory)
-
ScheduledTaskTrackingThreadPoolExecutor
public ScheduledTaskTrackingThreadPoolExecutor(int corePoolSize, RejectedExecutionHandler handler)
-
ScheduledTaskTrackingThreadPoolExecutor
public ScheduledTaskTrackingThreadPoolExecutor(int corePoolSize, ThreadFactory threadFactory, RejectedExecutionHandler handler)
-
-
Method Detail
-
beforeExecute
protected void beforeExecute(Thread worker, Runnable task)
Subclasses must callsuper.- Overrides:
beforeExecutein classThreadPoolExecutor
-
afterExecute
protected void afterExecute(Runnable task, Throwable error)
Subclasses must callsuper.- Overrides:
afterExecutein classThreadPoolExecutor
-
tryForceTerminate
public TaskTrackingExecutor.ForcedTerminationAftermath tryForceTerminate()
Description copied from interface:TaskTrackingExecutorCallsExecutorService.shutdownNow()and returns an object containing a list of tasks that were still running when this method was called, together with the list of tasks returned byExecutorService.shutdownNow().- Specified by:
tryForceTerminatein interfaceTaskTrackingExecutor
-
decorateTask
protected <V> ScheduledTaskTrackingThreadPoolExecutor.ScheduledExecution<V> decorateTask(Runnable task, RunnableScheduledFuture<V> scheduledExecution)
DecoratestaskusingScheduledTaskTrackingThreadPoolExecutor.ScheduledExecution.- Overrides:
decorateTaskin classScheduledThreadPoolExecutor
-
decorateTask
protected <V> ScheduledTaskTrackingThreadPoolExecutor.ScheduledExecution<V> decorateTask(Callable<V> task, RunnableScheduledFuture<V> scheduledExecution)
DecoratestaskusingScheduledTaskTrackingThreadPoolExecutor.ScheduledExecution.- Overrides:
decorateTaskin classScheduledThreadPoolExecutor
-
-