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, 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(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, NuxeoBlockingQueue queue, 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
RuntimeException
protected void beforeExecute(Thread t, Runnable r)
beforeExecute
in class ThreadPoolExecutor
protected void afterExecute(Runnable r, Throwable t)
afterExecute
in class ThreadPoolExecutor
public void shutdownAndSuspend() throws InterruptedException
InterruptedException
public void removeScheduled(String workId)
Copyright © 2017 Nuxeo. All rights reserved.