Package pl.morgwai.base.utils.concurrent
Class TaskTrackingThreadPoolExecutor
- java.lang.Object
-
- java.util.concurrent.AbstractExecutorService
-
- java.util.concurrent.ThreadPoolExecutor
-
- pl.morgwai.base.utils.concurrent.TaskTrackingThreadPoolExecutor
-
- All Implemented Interfaces:
Executor,ExecutorService,TaskTrackingExecutor,TaskTrackingExecutor.TaskTrackingExecutorDecorator.HookableExecutor
public class TaskTrackingThreadPoolExecutor extends ThreadPoolExecutor implements TaskTrackingExecutor, TaskTrackingExecutor.TaskTrackingExecutorDecorator.HookableExecutor
ATaskTrackingExecutorbased on aThreadPoolExecutor.
-
-
Nested Class Summary
-
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
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAfterExecuteHook(BiConsumer<Runnable,Throwable> hook)Adds hook to be executed inafterExecute(Runnable, Throwable).voidaddBeforeExecuteHook(BiConsumer<Thread,Runnable> hook)Addshookto be executed inbeforeExecute(Thread, Runnable).protected voidafterExecute(Runnable task, Throwable error)Executes alladdAfterExecuteHook(BiConsumer)added hooks} in the order they were added.protected voidbeforeExecute(Thread worker, Runnable task)Executes alladded hooksin the reverse order they were added.TaskTrackingExecutor.ForcedTerminationAftermathtryForceTerminate()CallsExecutorService.shutdownNow()and returns an object containing aListof tasks, that were still running right before the call.-
Methods inherited from class java.util.concurrent.ThreadPoolExecutor
allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, execute, 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
-
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
-
TaskTrackingThreadPoolExecutor
public TaskTrackingThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory, RejectedExecutionHandler handler)Callssuperand sets upTaskTrackingExecutor.TaskTrackingExecutorDecorator.
-
TaskTrackingThreadPoolExecutor
public TaskTrackingThreadPoolExecutor(int poolSize)
-
TaskTrackingThreadPoolExecutor
public TaskTrackingThreadPoolExecutor(int poolSize, int queueSize)
-
TaskTrackingThreadPoolExecutor
public TaskTrackingThreadPoolExecutor(int poolSize, int queueSize, ThreadFactory threadFactory)
-
TaskTrackingThreadPoolExecutor
public TaskTrackingThreadPoolExecutor(int poolSize, int queueSize, RejectedExecutionHandler handler)
-
TaskTrackingThreadPoolExecutor
public TaskTrackingThreadPoolExecutor(int poolSize, int queueSize, ThreadFactory threadFactory, RejectedExecutionHandler handler)
-
TaskTrackingThreadPoolExecutor
public TaskTrackingThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue)Callssuperand sets upTaskTrackingExecutor.TaskTrackingExecutorDecorator.
-
TaskTrackingThreadPoolExecutor
public TaskTrackingThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory)Callssuperand sets upTaskTrackingExecutor.TaskTrackingExecutorDecorator.
-
TaskTrackingThreadPoolExecutor
public TaskTrackingThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, RejectedExecutionHandler handler)Callssuperand sets upTaskTrackingExecutor.TaskTrackingExecutorDecorator.
-
-
Method Detail
-
tryForceTerminate
public TaskTrackingExecutor.ForcedTerminationAftermath tryForceTerminate()
Description copied from interface:TaskTrackingExecutorCallsExecutorService.shutdownNow()and returns an object containing aListof tasks, that were still running right before the call. The returned object also contains theListof tasks returned byExecutorService.shutdownNow()itself.- Specified by:
tryForceTerminatein interfaceTaskTrackingExecutor
-
addBeforeExecuteHook
public void addBeforeExecuteHook(BiConsumer<Thread,Runnable> hook)
Addshookto be executed inbeforeExecute(Thread, Runnable).- Specified by:
addBeforeExecuteHookin interfaceTaskTrackingExecutor.TaskTrackingExecutorDecorator.HookableExecutor
-
beforeExecute
protected final void beforeExecute(Thread worker, Runnable task)
Executes alladded hooksin the reverse order they were added.- Overrides:
beforeExecutein classThreadPoolExecutor
-
addAfterExecuteHook
public void addAfterExecuteHook(BiConsumer<Runnable,Throwable> hook)
Adds hook to be executed inafterExecute(Runnable, Throwable).- Specified by:
addAfterExecuteHookin interfaceTaskTrackingExecutor.TaskTrackingExecutorDecorator.HookableExecutor
-
afterExecute
protected final void afterExecute(Runnable task, Throwable error)
Executes alladdAfterExecuteHook(BiConsumer)added hooks} in the order they were added.- Overrides:
afterExecutein classThreadPoolExecutor
-
-