protected class WorkManagerImpl.WorkThreadPoolExecutor extends ThreadPoolExecutor
ThreadPoolExecutor
that keeps available the list of running tasks.
Completed tasks are passed to another queue.
The scheduled queue and completed list are passed as arguments and can have different implementations (in-memory, persisted, etc).
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy
Modifier and Type | Field and Description |
---|---|
protected com.codahale.metrics.Counter |
completedCount |
protected String |
queueId |
protected ConcurrentLinkedQueue<Work> |
running
List of running Work instances, in order to be able to interrupt them if requested.
|
protected com.codahale.metrics.Counter |
runningCount |
protected com.codahale.metrics.Counter |
scheduledCount |
protected com.codahale.metrics.Timer |
workTimer |
Modifier | Constructor and Description |
---|---|
protected |
WorkThreadPoolExecutor(String queueId,
int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
ThreadFactory threadFactory) |
Modifier and Type | Method and Description |
---|---|
protected void |
afterExecute(Runnable r,
Throwable t) |
boolean |
awaitTerminationOrSave(long timeout,
TimeUnit unit)
Blocks until all work instances have completed after a shutdown and suspend request.
|
protected void |
beforeExecute(Thread t,
Runnable r) |
void |
execute(Runnable r) |
void |
execute(Work work)
Executes the given task sometime in the future.
|
int |
getScheduledOrRunningSize() |
protected void |
removedFromQueue(Runnable r) |
Work |
removeScheduled(String workId) |
void |
shutdownAndSuspend()
Initiates a shutdown of this executor and asks for work instances to suspend themselves.
|
protected void |
submit(Work work)
go through the queue instead of using super.execute which may skip the queue and hand off to a thread
directly
|
allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, 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
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
protected final ConcurrentLinkedQueue<Work> running
protected final com.codahale.metrics.Counter scheduledCount
protected final com.codahale.metrics.Counter runningCount
protected final com.codahale.metrics.Counter completedCount
protected final com.codahale.metrics.Timer workTimer
protected WorkThreadPoolExecutor(String queueId, int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, ThreadFactory threadFactory)
public int getScheduledOrRunningSize()
public void execute(Runnable r)
execute
in interface Executor
execute
in class ThreadPoolExecutor
public void execute(Work work)
work
- the work to executeexecute(Runnable)
protected void submit(Work work) throws RuntimeException
work
- RuntimeException
protected void beforeExecute(Thread t, Runnable r)
beforeExecute
in class ThreadPoolExecutor
protected void afterExecute(Runnable r, Throwable t)
afterExecute
in class ThreadPoolExecutor
protected void removedFromQueue(Runnable r)
public void shutdownAndSuspend()
public boolean awaitTerminationOrSave(long timeout, TimeUnit unit) throws InterruptedException
timeout
- the time to waitunit
- the timeout unitInterruptedException
public Work removeScheduled(String workId)
Copyright © 2016 Nuxeo SA. All rights reserved.