T
- The work unit type.public class WorkQueue<T> extends Object implements AutoCloseable
Modifier and Type | Class and Description |
---|---|
static interface |
WorkQueue.WorkQueuePreStartHook<T>
A hook that is called once a WorkQueue is created, inside its try-with-resources block, before the workers
are started.
|
static interface |
WorkQueue.WorkUnitProcessor<T>
A work unit processor.
|
Constructor and Description |
---|
WorkQueue(Collection<T> initialWorkUnits,
WorkQueue.WorkUnitProcessor<T> workUnitProcessor,
InterruptionChecker interruptionChecker,
LogNode log)
A parallel work queue.
|
Modifier and Type | Method and Description |
---|---|
void |
addWorkUnits(Collection<T> workUnits)
Add multiple units of work.
|
void |
close()
Ensure that there are no work units still uncompleted.
|
void |
runWorkLoop()
Start a worker.
|
static <U> void |
runWorkQueue(Collection<U> elements,
ExecutorService executorService,
int numParallelTasks,
WorkQueue.WorkUnitProcessor<U> workUnitProcessor,
InterruptionChecker interruptionChecker,
LogNode log)
Start a work queue on the elements in the provided collection, blocking until all work units have been
completed.
|
static <U> void |
runWorkQueue(Collection<U> elements,
ExecutorService executorService,
int numParallelTasks,
WorkQueue.WorkUnitProcessor<U> workUnitProcessor,
WorkQueue.WorkQueuePreStartHook<U> workQueuePreStartHook,
InterruptionChecker interruptionChecker,
LogNode log)
Start a work queue on the elements in the provided collection, blocking until all work units have been
completed.
|
void |
startWorkers(ExecutorService executorService,
int numWorkers,
LogNode log)
Start worker threads with a shared log.
|
public WorkQueue(Collection<T> initialWorkUnits, WorkQueue.WorkUnitProcessor<T> workUnitProcessor, InterruptionChecker interruptionChecker, LogNode log)
public static <U> void runWorkQueue(Collection<U> elements, ExecutorService executorService, int numParallelTasks, WorkQueue.WorkUnitProcessor<U> workUnitProcessor, WorkQueue.WorkQueuePreStartHook<U> workQueuePreStartHook, InterruptionChecker interruptionChecker, LogNode log) throws ExecutionException, InterruptedException
public static <U> void runWorkQueue(Collection<U> elements, ExecutorService executorService, int numParallelTasks, WorkQueue.WorkUnitProcessor<U> workUnitProcessor, InterruptionChecker interruptionChecker, LogNode log) throws ExecutionException, InterruptedException
public void startWorkers(ExecutorService executorService, int numWorkers, LogNode log)
public void runWorkLoop() throws InterruptedException, ExecutionException
public void addWorkUnits(Collection<T> workUnits)
public void close() throws ExecutionException
close
in interface AutoCloseable
ExecutionException
Copyright © 2018. All rights reserved.