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(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
NuxeoBlockingQueue queue,
ThreadFactory threadFactory) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
afterExecute(Runnable r,
Throwable t) |
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() |
void |
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, toStringinvokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submitprotected 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(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, NuxeoBlockingQueue queue, ThreadFactory threadFactory)
public int getScheduledOrRunningSize()
public void execute(Runnable r)
execute in interface Executorexecute in class ThreadPoolExecutorpublic void execute(Work work)
work - the work to executeexecute(Runnable)protected void submit(Work work) throws RuntimeException
work - RuntimeExceptionprotected void beforeExecute(Thread t, Runnable r)
beforeExecute in class ThreadPoolExecutorprotected void afterExecute(Runnable r, Throwable t)
afterExecute in class ThreadPoolExecutorpublic void shutdownAndSuspend() throws InterruptedException
InterruptedExceptionpublic void removeScheduled(String workId)
Copyright © 2016 Nuxeo SA. All rights reserved.