O - The type of object for which work is registered.P - The type identifying a pipeline. This can be the same as <O>
or an appropriate hash value for the registered object.AbstractPipeliningExecutor instead.@Deprecated public abstract class AbstractPipeliningExecutor<O,P> extends AFThreadPoolExecutor
ThreadPoolExecutor, it behaves differently when
submitting a runnable together with an object. In this case all runnables
submitted for an object will be executed in the order they arrive. This is
similar to having a pipeline for each object. The amount of pipelines is
bound to the maximum amount of threads in the thread pool. This prevents
starving of a pipeline due to the other pipelines being never empty.
Note that pipelines are not assigned to one thread. As long as there is work in a pipeline, it will be executed by the same thread. As soon as a pipeline is empty, new work may be done by a different thread.
java.util.concurrent.ThreadPoolExecutor.AbortPolicy, java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardOldestPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardPolicy| Modifier and Type | Field and Description |
|---|---|
protected java.util.concurrent.atomic.AtomicInteger |
abortCount
Deprecated.
A counter for all flushs that aborted pending work.
|
protected java.util.concurrent.atomic.AtomicInteger |
flushPending
Deprecated.
A counter for pending flushs.
|
protected java.util.logging.Logger |
logger
Deprecated.
The logger for log messages, especially runtime exception occurring when
executing work.
|
protected java.util.Map<P,Pair<PipelineRunnable<P>,java.util.Queue<java.lang.Runnable>>> |
pipelines
Deprecated.
All existing pipelines and the corresponding runnables.
|
protected java.util.concurrent.atomic.AtomicBoolean |
shutdownPending
Deprecated.
Whether a shutdown has been requested.
|
activeThreads, completedTasks, submittedTasks| Modifier | Constructor and Description |
|---|---|
protected |
AbstractPipeliningExecutor(Adept2ThreadFactory threadFactory)
Deprecated.
Creates a new thread pool executor with an unlimited amount of pipelines
for different objects using the designate thread factory for creating
threads.
|
protected |
AbstractPipeliningExecutor(int limit,
Adept2ThreadFactory threadFactory)
Deprecated.
Creates a new thread pool executor with the designated number of pipelines
and threads for different objects using the designate thread factory for
creating threads.
|
| Modifier and Type | Method and Description |
|---|---|
void |
execute(O object,
java.lang.Runnable task)
Deprecated.
Executes the designated task for the designated object.
|
java.util.Map<P,java.util.Queue<java.lang.Runnable>> |
flushAndExecute(boolean abortPending,
java.lang.Runnable task)
Deprecated.
Flushes all pipelines and executes the designated task.
|
protected java.util.Map<P,java.util.Queue<java.lang.Runnable>> |
flushAndExecuteUnchecked(boolean abortPending,
java.lang.Runnable task)
Deprecated.
The same as
flushAndExecute(boolean, Runnable) but without the
check for a pending shutdown. |
protected abstract P |
getPipelineFor(O object)
Deprecated.
Gets the identifier determining the pipeline for the designated object
accordingly to the limit of the number of pipelines.
|
boolean |
isShutdown()
Deprecated.
|
protected boolean |
restartPipelines(boolean abortedPending)
Deprecated.
Restarts the pipelines after a flush.
|
void |
shutdown()
Deprecated.
Shutting down will reject new work (normal or flushing).
|
java.util.List<java.lang.Runnable> |
shutdownNow()
Deprecated.
This shutdown will reject new work (normal or flushing) and abort the
current work except of pending flushs.
|
<T> java.util.concurrent.Future<T> |
submit(O object,
java.util.concurrent.Callable<T> task)
Deprecated.
Submits the designated task for the designated object.
|
java.util.concurrent.Future<?> |
submit(O object,
java.lang.Runnable task)
Deprecated.
Submits the designated task for the designated object.
|
<T> Pair<java.util.concurrent.Future<T>,java.util.Map<P,java.util.Queue<java.lang.Runnable>>> |
submitAndFlush(boolean abortPending,
java.util.concurrent.Callable<T> task)
Deprecated.
Submits the designated task and flushes all pipelines.
|
afterExecute, beforeExecute, execute, newTaskFor, newTaskFor, setLogExecuteCallStack, updateQueueLimitallowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, terminated, toStringprotected final java.util.Map<P,Pair<PipelineRunnable<P>,java.util.Queue<java.lang.Runnable>>> pipelines
protected final java.util.concurrent.atomic.AtomicInteger flushPending
protected final java.util.concurrent.atomic.AtomicInteger abortCount
protected final java.util.concurrent.atomic.AtomicBoolean shutdownPending
protected final java.util.logging.Logger logger
protected AbstractPipeliningExecutor(Adept2ThreadFactory threadFactory)
threadFactory - The factory to use when the executor creates a new
thread.protected AbstractPipeliningExecutor(int limit,
Adept2ThreadFactory threadFactory)
limit - The maximum number of threads allowed in the pool and also the
maximum number of pipelines.threadFactory - The factory to use when the executor creates a new
thread.public void execute(O object, java.lang.Runnable task)
object - The object for which to execute the designated task.task - The task which to execute.java.util.concurrent.RejectedExecutionException - if the executor has been
shut down.AFThreadPoolExecutor.execute(Runnable)public java.util.Map<P,java.util.Queue<java.lang.Runnable>> flushAndExecute(boolean abortPending, java.lang.Runnable task)
null
will be returned and the pipelines will restart work after the designated
task has been executed. abortPending - Whether the present work should be cancelled. In this
case the corresponding runnables will be returned.task - The task which to execute without any pipeline running.null in case no abortion is requested, otherwise the
pipelines and the aborted work.java.util.concurrent.RejectedExecutionException - if the executor has been
shut down.protected java.util.Map<P,java.util.Queue<java.lang.Runnable>> flushAndExecuteUnchecked(boolean abortPending, java.lang.Runnable task)
flushAndExecute(boolean, Runnable) but without the
check for a pending shutdown. This is required for the shutdown procedure.abortPending - Whether the present work should be cancelled. In this
case the corresponding runnables will be returned.task - The task which to execute without any pipeline running.null in case no abortion is requested, otherwise the
pipelines and the aborted work.java.util.concurrent.RejectedExecutionException - if the executor has been
shut down.public java.util.concurrent.Future<?> submit(O object, java.lang.Runnable task)
object - The object for which to execute the designated task.task - The task which to execute.Future representing pending completion of the taskjava.util.concurrent.RejectedExecutionException - if the executor has been
shut down.AbstractExecutorService.submit(Runnable)public <T> java.util.concurrent.Future<T> submit(O object, java.util.concurrent.Callable<T> task)
object - The object for which to execute the designated task.task - The task which to execute.Future representing pending completion of the taskjava.util.concurrent.RejectedExecutionException - if the executor has been
shut down.AbstractExecutorService.submit(Callable)public <T> Pair<java.util.concurrent.Future<T>,java.util.Map<P,java.util.Queue<java.lang.Runnable>>> submitAndFlush(boolean abortPending, java.util.concurrent.Callable<T> task)
null
will be returned and the pipelines will restart work after the designated
task has been executed. abortPending - Whether the present work should be cancelled. In this
case the corresponding runnables will be returned.task - The task which to execute without any pipeline running.null in case no abortion is
requested or the pipelines and the aborted work.java.util.concurrent.RejectedExecutionException - if the executor has been
shut down.flushAndExecute(boolean, Runnable)protected boolean restartPipelines(boolean abortedPending)
abortedPending - Whether the flush leading to this restart has aborted
pending work.public void shutdown()
shutdown in interface java.util.concurrent.ExecutorServiceshutdown in class java.util.concurrent.ThreadPoolExecutorpublic java.util.List<java.lang.Runnable> shutdownNow()
shutdownNow in interface java.util.concurrent.ExecutorServiceshutdownNow in class java.util.concurrent.ThreadPoolExecutorpublic boolean isShutdown()
isShutdown in interface java.util.concurrent.ExecutorServiceisShutdown in class java.util.concurrent.ThreadPoolExecutorprotected abstract P getPipelineFor(O object)
object - The object for which to determine the pipeline.