T - The work unit type.public class WorkQueue<T>
extends java.lang.Object
implements java.lang.AutoCloseable
| Modifier and Type | Class and Description |
|---|---|
static interface |
WorkQueue.WorkUnitProcessor<T>
A work unit processor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addWorkUnit(T workUnit)
Add a unit of work.
|
void |
addWorkUnits(java.util.Collection<T> workUnits)
Add multiple units of work.
|
void |
close()
Completion barrier for work queue.
|
static <U> void |
runWorkQueue(java.util.Collection<U> elements,
java.util.concurrent.ExecutorService executorService,
InterruptionChecker interruptionChecker,
int numParallelTasks,
LogNode log,
WorkQueue.WorkUnitProcessor<U> workUnitProcessor)
Start a work queue on the elements in the provided collection, blocking until all work units have been
completed.
|
public static <U> void runWorkQueue(java.util.Collection<U> elements,
java.util.concurrent.ExecutorService executorService,
InterruptionChecker interruptionChecker,
int numParallelTasks,
LogNode log,
WorkQueue.WorkUnitProcessor<U> workUnitProcessor)
throws java.lang.InterruptedException,
java.util.concurrent.ExecutionException
U - The type of the work queue units.elements - The work queue units to process.executorService - The ExecutorService.interruptionChecker - the interruption checkernumParallelTasks - The number of parallel tasks.log - The log.workUnitProcessor - The WorkQueue.WorkUnitProcessor.java.lang.InterruptedException - If the work was interrupted.java.util.concurrent.ExecutionException - If a worker throws an uncaught exception.public void addWorkUnit(T workUnit)
workUnit - the work unitjava.lang.NullPointerException - if the work unit is null.public void addWorkUnits(java.util.Collection<T> workUnits)
workUnits - The work units to add to the tail of the queue.java.lang.NullPointerException - if any of the work units are null.public void close()
throws java.util.concurrent.ExecutionException
close in interface java.lang.AutoCloseablejava.util.concurrent.ExecutionException - If a worker threw an uncaught exception.