public static class WorkManagerImpl.WorkThreadPoolExecutor extends ThreadPoolExecutor
ThreadPoolExecutor
that keeps available the list of scheduled,
running and completed tasks and provides other methods.
The methods checking the sizes are sure not to lose tasks in transit between the various queues.
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy
Constructor and Description |
---|
WorkManagerImpl.WorkThreadPoolExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> queue,
ThreadFactory threadFactory) |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTerminationOrSave(long timeout,
TimeUnit unit)
Blocks until all work instances have completed after a shutdown and
suspend request.
|
boolean |
cancelScheduled(Work work)
Removes any work instances equal to this one from the scheduled queue
and cancels them.
|
void |
clearCompleted()
Clears the completed tasks.
|
void |
clearCompleted(long completionTime)
Clears the completed tasks older than the given date.
|
void |
execute(Runnable r) |
Work |
find(Work work,
Work.State state,
boolean useEquals,
int[] pos)
Finds a work instance in the scheduled or running queue.
|
List<Work> |
getCompleted()
Gets the completed tasks.
|
List<Work> |
getNonCompleted()
Gets the non-completed tasks.
|
int |
getNonCompletedWorkSize()
Gets the number of non-completed tasks.
|
List<Work> |
getRunning()
Gets the running tasks.
|
List<Work> |
getScheduled()
Gets the scheduled tasks.
|
void |
shutdownAndSuspend()
Initiates a shutdown of this executor and asks for work instances to
suspend themselves.
|
void |
suspend()
Requests all running and scheduled work instances to suspend.
|
allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, 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, toString
public WorkManagerImpl.WorkThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> queue, ThreadFactory threadFactory)
public boolean cancelScheduled(Work work)
work
- the work to canceltrue
if there was work to cancelpublic Work find(Work work, Work.State state, boolean useEquals, int[] pos)
work
- the work to findstate
- the state defining the queue to look in,
SCHEDULED
, RUNNING
, COMPLETED
, or
null
for non-completeduseEquals
- if true
then use Work#equals
to find
the work instance, otherwise use object identitypos
- a 1-element array to return the position in the internal
queuepublic void execute(Runnable r)
execute
in interface Executor
execute
in class ThreadPoolExecutor
public void shutdownAndSuspend()
public boolean awaitTerminationOrSave(long timeout, TimeUnit unit) throws InterruptedException
timeout
- the time to waitunit
- the timeout unitInterruptedException
public void suspend()
public int getNonCompletedWorkSize()
public void clearCompleted()
public void clearCompleted(long completionTime)
Copyright © 2012 Nuxeo SA. All Rights Reserved.