F - the type of the factory for the input processorspublic class ConcurrentComputation<F extends ProcessorFactory<?>> extends Object implements InterruptMonitor
ProcessorFactory
. Processing is performed concurrently by several workers, each using a
Processor created by the ProcessorFactory. Processing starts
by calling start(), which creates a specified number of working
threads and starts concurrent processing. All workers can be interrupted by
interrupting the InterruptMonitor passed to this computation and the
ProcessorFactory. When finish() is called, the current
thread blocks until everything is processed by the workers or all workers
have been interrupted.| Modifier and Type | Field and Description |
|---|---|
protected ConcurrentExecutor |
executor
the executor used internally to run the jobs
|
protected JobMonitor |
jobMonitor
the object to monitor progress of the job
|
protected int |
maxWorkers
maximum number of concurrent workers
|
protected F |
processorFactory
the factory for the input processor engines
|
protected boolean |
termination
true the workers should stop either as soon as possible (if the
computation has been terminated) or after finish() is called |
protected Runnable |
worker
the worker instance used to process the jobs
|
| Constructor and Description |
|---|
ConcurrentComputation(F processorFactory,
ConcurrentExecutor executor,
int maxWorkers)
Creating a
ConcurrentComputation instance. |
| Modifier and Type | Method and Description |
|---|---|
void |
finish()
Requests all workers to terminate when processing is finished.
|
boolean |
isInterrupted() |
boolean |
start()
Starts the workers to process the input.
|
protected void |
waitWorkers() |
protected final F extends ProcessorFactory<?> processorFactory
protected final int maxWorkers
protected final ConcurrentExecutor executor
protected volatile boolean termination
true the workers should stop either as soon as possible (if the
computation has been terminated) or after finish() is calledprotected final Runnable worker
protected JobMonitor jobMonitor
public ConcurrentComputation(F processorFactory, ConcurrentExecutor executor, int maxWorkers)
ConcurrentComputation instance.processorFactory - the factory for input processorsexecutor - the executor used internally to run the jobsmaxWorkers - the maximal number of concurrent workers processing the jobspublic boolean start()
true if the operation was successfulprotected void waitWorkers()
throws InterruptedException
InterruptedExceptionpublic void finish()
throws InterruptedException
InterruptedException - if interrupted during waiting for finish requestpublic boolean isInterrupted()
isInterrupted in interface InterruptMonitortrue after this monitor was notified about interruption,
false if it was not.Copyright © 2011–2024 Live Ontologies Project. All rights reserved.