I - the type of the input to be processed.F - the type of the factory for the input processorspublic class ConcurrentComputationWithInputs<I,F extends InputProcessorFactory<I,?>> extends ConcurrentComputation<F>
InputProcessor objects created by the supplied
InputProcessorFactory. The implementation is loosely based on a
producer-consumer framework with one producer and many consumers. The
processing of the input should start by calling the ConcurrentComputation.start() method,
following by submit(Object) method for submitting input to be
processed. The workers will always wait for new input, unless interrupted or
ConcurrentComputation.finish() method is called. If ConcurrentComputation.finish() is called then no
further input can be submitted and the workers will terminate when all input
has been processed or they are interrupted earlier, whichever is earlier.executor, jobMonitor, maxWorkers, processorFactory, termination, worker| Constructor and Description |
|---|
ConcurrentComputationWithInputs(F inputProcessorFactory,
ConcurrentExecutor executor,
int maxWorkers)
Creating a
ConcurrentComputationWithInputs instance. |
ConcurrentComputationWithInputs(F inputProcessorFactory,
ConcurrentExecutor executor,
int maxWorkers,
int bufferCapacity)
Creating a
ConcurrentComputationWithInputs instance. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
submit(I input)
Submitting a new input for processing.
|
protected void |
waitWorkers() |
finish, isInterrupted, startpublic ConcurrentComputationWithInputs(F inputProcessorFactory, ConcurrentExecutor executor, int maxWorkers, int bufferCapacity)
ConcurrentComputationWithInputs instance.inputProcessorFactory - the factory for input processorsexecutor - the executor used internally to run the jobsmaxWorkers - the maximal number of concurrent workers processing the jobsbufferCapacity - the size of the buffer for scheduled jobs; if the buffer is
full, submitting new jobs will block until new space is
availablepublic ConcurrentComputationWithInputs(F inputProcessorFactory, ConcurrentExecutor executor, int maxWorkers)
ConcurrentComputationWithInputs instance.inputProcessorFactory - the factory for input processorsexecutor - the executor used internally to run the jobsmaxWorkers - the maximal number of concurrent workers processing the jobspublic boolean submit(I input) throws InterruptedException
input - the input to be processedtrue if the input has been successfully submitted for
computation; the input cannot be submitted, e.g., if
ConcurrentComputation.finish() has been calledInterruptedException - thrown if interrupted during waiting for space to be
availableprotected void waitWorkers()
throws InterruptedException
waitWorkers in class ConcurrentComputation<F extends InputProcessorFactory<I,?>>InterruptedExceptionCopyright © 2011–2024 Live Ontologies Project. All rights reserved.