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.public abstract class AbstractPipeliningExecutor<O,P> extends AbstractObjectSpecificExecutor<O,P,java.util.Queue<java.lang.Runnable>>
As object-specific executor, the indexed objects are the pipelines while the runtime data are
queues of runnables which are part of the corresponding pipeline that need to be executed. There
is exactly one thread in the pool per pipeline.
Note that the assignment of pipelines to threads is not fixed. 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 in
this pipeline 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.DiscardPolicyabortCount, flushPending, logger, objects, shutdownPendingfullSize, realCoreSize, realMaxSize, workSizeactiveThreads, completedTasks, submittedTasks| Modifier | Constructor and Description |
|---|---|
protected |
AbstractPipeliningExecutor(Adept2ThreadFactory threadFactory)
Creates a new thread pool executor with an unlimited amount of pipelines
for different objects using the designated thread factory for creating
threads.
|
protected |
AbstractPipeliningExecutor(int limit,
Adept2ThreadFactory threadFactory)
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 |
|---|---|
protected ObjectRunnable<O,P> |
addRunnable(O registeredObject,
P indexObject,
java.lang.Runnable task)
Adds the designated runnable for the designated object and index object to this executor.
|
protected <T> Pair<java.util.concurrent.Future<T>,java.util.Map<P,java.util.Queue<java.lang.Runnable>>> |
cancelAndFlush(boolean shutdownRequest,
java.util.Map<P,java.util.Queue<java.lang.Runnable>> pending,
java.util.concurrent.Callable<T> task,
java.util.Collection<ObjectRunnable<O,P>> objectRunnables)
Cancels the designated pending work (if appropriate), flushes (i. e. waits for or aborts the
designated runnables) and executes the designated task.
|
protected void |
clearAbortedPendingWork(boolean shutdownRequest)
Removes all pending work that should be aborted for an aborting flush, that is, it removes the
from the data structures, e. g.
|
protected void |
executeShutdown(java.lang.Runnable shutdown)
Executes the designated shutdown task which contains a flush calling
ThreadPoolExecutor.shutdown() without abortion. |
protected java.util.List<java.lang.Runnable> |
getOutstandingRunnables(java.util.Map<P,java.util.Queue<java.lang.Runnable>> outstandingWork)
Gets a list of runnables which have not been executed based on the designated outstanding work.
|
execute, flushAndExecute, flushAndExecuteUnchecked, getIndexObjectFor, isShutdown, restart, restartPendingWork, shutdown, shutdownNow, shutdownRunnableRun, submit, submit, submitAndFlushafterExecute, executebeforeExecute, 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 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.protected ObjectRunnable<O,P> addRunnable(O registeredObject, P indexObject, java.lang.Runnable task)
AbstractObjectSpecificExecutorCachedThreadPoolExecutor.execute(Runnable). If they return null, they
have to assign the runnable to an active element eventually and arbitrarily.
The caller has the lock on objects.
addRunnable in class AbstractObjectSpecificExecutor<O,P,java.util.Queue<java.lang.Runnable>>registeredObject - The object for which this runnable has been registered.indexObject - The object with which this runnable is managed and executed within the
corresponding object-specific executor service.task - The task which to execute.CachedThreadPoolExecutor.execute(Runnable), which means the runnable
will be executed independently from other work and a new thread may be started for it.protected void clearAbortedPendingWork(boolean shutdownRequest)
AbstractObjectSpecificExecutorobjects. This method only affects data structures,
it does not affect any executed work. The caller will take care of this shortly.
The caller has the lock on objects.
clearAbortedPendingWork in class AbstractObjectSpecificExecutor<O,P,java.util.Queue<java.lang.Runnable>>shutdownRequest - Whether this flush is caused by a AbstractObjectSpecificExecutor.shutdownNow(). In this case
all work has to be aborted, even the work pending after a flush.protected <T> Pair<java.util.concurrent.Future<T>,java.util.Map<P,java.util.Queue<java.lang.Runnable>>> cancelAndFlush(boolean shutdownRequest, java.util.Map<P,java.util.Queue<java.lang.Runnable>> pending, java.util.concurrent.Callable<T> task, java.util.Collection<ObjectRunnable<O,P>> objectRunnables)
AbstractObjectSpecificExecutor
The caller has the lock on objects.
cancelAndFlush in class AbstractObjectSpecificExecutor<O,P,java.util.Queue<java.lang.Runnable>>shutdownRequest - Whether this flush is caused by a AbstractObjectSpecificExecutor.shutdownNow(). In this case
all work has to be aborted, even the work pending after a flush.pending - The pending work that will not be executed due to abort or null if
running work should not be aborted.task - The task which to execute without any object work running.objectRunnables - The currently running work. This will either be aborted or awaited for
flushing.null in case no abortion is requested otherwise the managed objects
and the runtime data of the aborted work. Note that the runtime data may contain work
that is not cancelled by the flush. This depends on the runtime data.protected void executeShutdown(java.lang.Runnable shutdown)
AbstractObjectSpecificExecutorThreadPoolExecutor.shutdown() without abortion.
The caller has the lock on objects.
executeShutdown in class AbstractObjectSpecificExecutor<O,P,java.util.Queue<java.lang.Runnable>>shutdown - The task which to perform to shutdown.protected java.util.List<java.lang.Runnable> getOutstandingRunnables(java.util.Map<P,java.util.Queue<java.lang.Runnable>> outstandingWork)
AbstractObjectSpecificExecutorobjects.getOutstandingRunnables in class AbstractObjectSpecificExecutor<O,P,java.util.Queue<java.lang.Runnable>>outstandingWork - The pending work that has been aborted due to the immediate shutdown.