Class ObjectOneWorkExecutor<O>
- java.lang.Object
-
- java.util.concurrent.AbstractExecutorService
-
- java.util.concurrent.ThreadPoolExecutor
-
- de.aristaflow.adept2.util.threading.AFThreadPoolExecutor
-
- de.aristaflow.adept2.util.threading.CachedThreadPoolExecutor
-
- de.aristaflow.adept2.util.threading.executor.AbstractObjectSpecificExecutor<O,O,R>
-
- de.aristaflow.adept2.util.threading.executor.AbstractObjectOneWorkExecutor<O,AbstractObjectOneWorkExecutor.RuntimeData>
-
- de.aristaflow.adept2.util.threading.executor.ObjectOneWorkExecutor<O>
-
- Type Parameters:
O
- The type of object for which work is registered.
- All Implemented Interfaces:
Executor
,ExecutorService
public class ObjectOneWorkExecutor<O> extends AbstractObjectOneWorkExecutor<O,AbstractObjectOneWorkExecutor.RuntimeData>
This one work executor simply uses the normal runtime data that is, it allows for one piece of work for each object pending before and after a flush.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class de.aristaflow.adept2.util.threading.executor.AbstractObjectOneWorkExecutor
AbstractObjectOneWorkExecutor.RuntimeData
-
Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy
-
-
Field Summary
-
Fields inherited from class de.aristaflow.adept2.util.threading.executor.AbstractObjectOneWorkExecutor
blockUntilFlush, overridingWork
-
Fields inherited from class de.aristaflow.adept2.util.threading.executor.AbstractObjectSpecificExecutor
abortCount, flushPending, logger, objects, shutdownPending
-
Fields inherited from class de.aristaflow.adept2.util.threading.CachedThreadPoolExecutor
fullSize, realCoreSize, realMaxSize, workSize
-
Fields inherited from class de.aristaflow.adept2.util.threading.AFThreadPoolExecutor
activeThreads, completedTasks, HYSTERESIS, submittedTasks
-
-
Constructor Summary
Constructors Constructor Description ObjectOneWorkExecutor(boolean blockUntilFlush, int corePoolSize, int maxPoolSize, boolean prestart, Adept2ThreadFactory threadFactory)
Deprecated, for removal: This API element is subject to removal in a future version.ObjectOneWorkExecutor(boolean blockUntilFlush, int corePoolSize, int maxPoolSize, boolean prestart, Adept2ThreadFactory threadFactory, int queueLimitPoolStatistics, Level minLogLevelPoolStatistics)
Deprecated, for removal: This API element is subject to removal in a future version.ObjectOneWorkExecutor(boolean blockUntilFlush, int corePoolSize, int maxPoolSize, Adept2ThreadFactory threadFactory)
Creates a new thread pool executor with the designated (maximum) amount of (core) threads (and unlimited objects), accepting exactly one piece of work per object.ObjectOneWorkExecutor(boolean blockUntilFlush, int corePoolSize, int maxPoolSize, Adept2ThreadFactory threadFactory, int queueLimitPoolStatistics, Level minLogLevelPoolStatistics)
Creates a new thread pool executor with the designated (maximum) amount of (core) threads (and unlimited objects), accepting exactly one piece of work per object.ObjectOneWorkExecutor(boolean blockUntilFlush, int maxPoolSize, Adept2ThreadFactory threadFactory)
Creates a new thread pool executor with an unlimited amount objects and the designated maximum amount of threads, accepting exactly one piece of work per object.ObjectOneWorkExecutor(boolean blockUntilFlush, Adept2ThreadFactory threadFactory)
Deprecated, for removal: This API element is subject to removal in a future version.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected AbstractObjectOneWorkExecutor.RuntimeData
addNewPendingAfterFlush(AbstractObjectOneWorkExecutor.RuntimeData rtData, Runnable pendingAfterFlush)
Creates runtime data having the same data as the designated runtime data except for the pending after flush which will be the designated runnable.protected AbstractObjectOneWorkExecutor.RuntimeData
addNewPendingBeforeFlush(Runnable pendingBeforeFlush, AbstractObjectOneWorkExecutor.RuntimeData rtData)
Creates runtime data having the same data as the designated runtime data except for the pending before flush which will be the designated runnable.protected AbstractObjectOneWorkExecutor.RuntimeData
createPendingAfterFlush(Runnable pendingAfterFlush)
Creates runtime data having the designated runnable as pending after flush.protected AbstractObjectOneWorkExecutor.RuntimeData
createPendingBeforeFlush(Runnable pendingBeforeFlush)
Creates runtime data having the designated runnable as pending before flush.protected AbstractObjectOneWorkExecutor.RuntimeData
removePendingBeforeFlush(AbstractObjectOneWorkExecutor.RuntimeData rtData)
Creates runtime data having the same data as the designated runtime data except for the pending before flush which will benull
.protected AbstractObjectOneWorkExecutor.RuntimeData
switchPendingAfterFlush(AbstractObjectOneWorkExecutor.RuntimeData rtData)
Creates runtime data having pending before flush taken from pending after flush from the designated runtime and pending after flush beingnull
.-
Methods inherited from class de.aristaflow.adept2.util.threading.executor.AbstractObjectOneWorkExecutor
addRunnable, cancelAndFlush, clearAbortedPendingWork, createObjectOneWorkRunnable, executeOverride, executeShutdown, getIndexObjectFor, getOutstandingRunnables, restartPendingWork, submitOverride, submitOverride
-
Methods inherited from class de.aristaflow.adept2.util.threading.executor.AbstractObjectSpecificExecutor
execute, flushAndExecute, flushAndExecuteUnchecked, isShutdown, restart, shutdown, shutdownNow, shutdownRunnableRun, submit, submit, submitAndFlush
-
Methods inherited from class de.aristaflow.adept2.util.threading.CachedThreadPoolExecutor
afterExecute, execute
-
Methods inherited from class de.aristaflow.adept2.util.threading.AFThreadPoolExecutor
beforeExecute, logPoolStatistics, newTaskFor, newTaskFor, recalculateLogLimits, setCorePoolSize, setLogExecuteCallStack, setMaximumPoolSize, updateQueueLimit
-
Methods inherited from class java.util.concurrent.ThreadPoolExecutor
allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setKeepAliveTime, setRejectedExecutionHandler, setThreadFactory, terminated, toString
-
-
-
-
Constructor Detail
-
ObjectOneWorkExecutor
@Deprecated(since="14.4.0", forRemoval=true) public ObjectOneWorkExecutor(boolean blockUntilFlush, Adept2ThreadFactory threadFactory)
Deprecated, for removal: This API element is subject to removal in a future version.Creates a new thread pool executor with an unlimited amount of threads and objects, accepting exactly one piece of work per object. It uses the designated thread factory for creating threads. The threads will stay idle for 60 seconds before they terminate.- Parameters:
blockUntilFlush
- Whether work should be blocked for each object until the next flush. Otherwise work is allowed as soon as the work of the object has started.threadFactory
- The factory to use when the executor creates a new thread.
-
ObjectOneWorkExecutor
public ObjectOneWorkExecutor(boolean blockUntilFlush, int maxPoolSize, Adept2ThreadFactory threadFactory)
Creates a new thread pool executor with an unlimited amount objects and the designated maximum amount of threads, accepting exactly one piece of work per object. It uses the designated thread factory for creating threads. The threads will stay idle for 60 seconds before they terminate.- Parameters:
blockUntilFlush
- Whether work should be blocked for each object until the next flush. Otherwise work is allowed as soon as the work of the object has started.maxPoolSize
- The maximum number of threads allowed in the pool. Set this to the number of objects allowed to be executed concurrently or less.threadFactory
- The factory to use when the executor creates a new thread.
-
ObjectOneWorkExecutor
public ObjectOneWorkExecutor(boolean blockUntilFlush, int corePoolSize, int maxPoolSize, Adept2ThreadFactory threadFactory)
Creates a new thread pool executor with the designated (maximum) amount of (core) threads (and unlimited objects), accepting exactly one piece of work per object. It uses the designated thread factory for creating threads. The threads will stay idle for 60 seconds before they terminate.- Parameters:
blockUntilFlush
- Whether work should be blocked for each object until the next flush. Otherwise work is allowed as soon as the work of the object has started.corePoolSize
- The number of threads to keep in the pool all the time, even if they are idle.maxPoolSize
- The maximum number of threads allowed in the pool. Set this to the number of objects allowed to be executed concurrently or less.threadFactory
- The factory to use when the executor creates a new thread.
-
ObjectOneWorkExecutor
@Deprecated(since="14.4.0", forRemoval=true) public ObjectOneWorkExecutor(boolean blockUntilFlush, int corePoolSize, int maxPoolSize, boolean prestart, Adept2ThreadFactory threadFactory)
Deprecated, for removal: This API element is subject to removal in a future version.Creates a new thread pool executor with the designated (maximum) amount of (core) threads (and unlimited objects), accepting exactly one piece of work per object. It uses the designated thread factory for creating threads. The threads will stay idle for 60 seconds before they terminate.- Parameters:
blockUntilFlush
- Whether work should be blocked for each object until the next flush. Otherwise work is allowed as soon as the work of the object has started.corePoolSize
- The number of threads to keep in the pool, even if they are idle.maxPoolSize
- The maximum number of threads to allow in the pool.prestart
- Whether all core threads should be prestarted.threadFactory
- The factory to use when the executor creates a new thread.
-
ObjectOneWorkExecutor
public ObjectOneWorkExecutor(boolean blockUntilFlush, int corePoolSize, int maxPoolSize, Adept2ThreadFactory threadFactory, int queueLimitPoolStatistics, Level minLogLevelPoolStatistics)
Creates a new thread pool executor with the designated (maximum) amount of (core) threads (and unlimited objects), accepting exactly one piece of work per object. It uses the designated thread factory for creating threads. The threads will stay idle for 60 seconds before they terminate.- Parameters:
blockUntilFlush
- Whether work should be blocked for each object until the next flush. Otherwise work is allowed as soon as the work of the object has started.corePoolSize
- The number of threads to keep in the pool all the time, even if they are idle.maxPoolSize
- The maximum number of threads allowed in the pool. Set this to the number of objects allowed to be executed concurrently or less.threadFactory
- The factory to use when the executor creates a new thread.queueLimitPoolStatistics
- The amount of tasks in the queue before warnings will be logged. Use-1
to use the default limits.minLogLevelPoolStatistics
- The log level which need to be reached for logging pool statistics. Pool statistics logs with a lower log level will be ignored.
-
ObjectOneWorkExecutor
@Deprecated(since="14.4.0", forRemoval=true) public ObjectOneWorkExecutor(boolean blockUntilFlush, int corePoolSize, int maxPoolSize, boolean prestart, Adept2ThreadFactory threadFactory, int queueLimitPoolStatistics, Level minLogLevelPoolStatistics)
Deprecated, for removal: This API element is subject to removal in a future version.Creates a new thread pool executor with the designated (maximum) amount of (core) threads (and unlimited objects), accepting exactly one piece of work per object. It uses the designated thread factory for creating threads. The threads will stay idle for 60 seconds before they terminate.- Parameters:
blockUntilFlush
- Whether work should be blocked for each object until the next flush. Otherwise work is allowed as soon as the work of the object has started.corePoolSize
- The number of threads to keep in the pool, even if they are idle.maxPoolSize
- The maximum number of threads to allow in the pool.prestart
- Whether all core threads should be prestarted.threadFactory
- The factory to use when the executor creates a new thread.queueLimitPoolStatistics
- The amount of tasks in the queue before warnings will be logged. Use-1
to use the default limits.minLogLevelPoolStatistics
- The log level which need to be reached for logging pool statistics. Pool statistics logs with a lower log level will be ignored.
-
-
Method Detail
-
createPendingBeforeFlush
protected AbstractObjectOneWorkExecutor.RuntimeData createPendingBeforeFlush(Runnable pendingBeforeFlush)
Description copied from class:AbstractObjectOneWorkExecutor
Creates runtime data having the designated runnable as pending before flush.- Specified by:
createPendingBeforeFlush
in classAbstractObjectOneWorkExecutor<O,AbstractObjectOneWorkExecutor.RuntimeData>
- Parameters:
pendingBeforeFlush
- The runnable which to have as pending before flush.- Returns:
- Newly created runtime data having the designated runnable as pending before flush.
-
createPendingAfterFlush
protected AbstractObjectOneWorkExecutor.RuntimeData createPendingAfterFlush(Runnable pendingAfterFlush)
Description copied from class:AbstractObjectOneWorkExecutor
Creates runtime data having the designated runnable as pending after flush.- Specified by:
createPendingAfterFlush
in classAbstractObjectOneWorkExecutor<O,AbstractObjectOneWorkExecutor.RuntimeData>
- Parameters:
pendingAfterFlush
- The runnable which to have as pending after flush.- Returns:
- Newly created runtime data having the designated runnable as pending after flush.
-
addNewPendingBeforeFlush
protected AbstractObjectOneWorkExecutor.RuntimeData addNewPendingBeforeFlush(Runnable pendingBeforeFlush, AbstractObjectOneWorkExecutor.RuntimeData rtData)
Description copied from class:AbstractObjectOneWorkExecutor
Creates runtime data having the same data as the designated runtime data except for the pending before flush which will be the designated runnable.- Specified by:
addNewPendingBeforeFlush
in classAbstractObjectOneWorkExecutor<O,AbstractObjectOneWorkExecutor.RuntimeData>
- Parameters:
pendingBeforeFlush
- The runnable which to have as pending before flush.rtData
- The runtime data from which to take over most of the data.- Returns:
- Runtime data having the same data as the designated runtime data except for the pending before flush which will be the designated runnable.
-
addNewPendingAfterFlush
protected AbstractObjectOneWorkExecutor.RuntimeData addNewPendingAfterFlush(AbstractObjectOneWorkExecutor.RuntimeData rtData, Runnable pendingAfterFlush)
Description copied from class:AbstractObjectOneWorkExecutor
Creates runtime data having the same data as the designated runtime data except for the pending after flush which will be the designated runnable.- Specified by:
addNewPendingAfterFlush
in classAbstractObjectOneWorkExecutor<O,AbstractObjectOneWorkExecutor.RuntimeData>
- Parameters:
rtData
- The runtime data from which to take over most of the data.pendingAfterFlush
- The runnable which to have as pending after flush.- Returns:
- Runtime data having the same data as the designated runtime data except for the pending after flush which will be the designated runnable.
-
removePendingBeforeFlush
protected AbstractObjectOneWorkExecutor.RuntimeData removePendingBeforeFlush(AbstractObjectOneWorkExecutor.RuntimeData rtData)
Description copied from class:AbstractObjectOneWorkExecutor
Creates runtime data having the same data as the designated runtime data except for the pending before flush which will benull
.- Specified by:
removePendingBeforeFlush
in classAbstractObjectOneWorkExecutor<O,AbstractObjectOneWorkExecutor.RuntimeData>
- Parameters:
rtData
- The runtime data from which to take over most of the data.- Returns:
- Runtime data having the same data as the designated runtime data except for the pending
before flush which will be
null
.
-
switchPendingAfterFlush
protected AbstractObjectOneWorkExecutor.RuntimeData switchPendingAfterFlush(AbstractObjectOneWorkExecutor.RuntimeData rtData)
Description copied from class:AbstractObjectOneWorkExecutor
Creates runtime data having pending before flush taken from pending after flush from the designated runtime and pending after flush beingnull
.
This has to be called when restarting after a flush.- Specified by:
switchPendingAfterFlush
in classAbstractObjectOneWorkExecutor<O,AbstractObjectOneWorkExecutor.RuntimeData>
- Parameters:
rtData
- The runtime data from which to take over the data.- Returns:
- Runtime data having pending before flush taken from pending after flush from the
designated runtime and pending after flush being
null
.
-
-