chemaxon.util.concurrent
Interface ConcurrentProcessor

All Superinterfaces:
Cancelable, chemaxon.util.concurrent.util.ConcurrentIterator

public interface ConcurrentProcessor
extends chemaxon.util.concurrent.util.ConcurrentIterator, Cancelable

Executes jobs in parallel and returns their results iterator-style.

Author:
pkovacs

Method Summary
 void cleanup()
          Calls cleanup(long) with Long.MAX_VALUE.
 void cleanup(long joinTimeout)
          Awaits termination of worker threads executing on behalf of this processor and releases any resource this processor has reserved.
 void setWorkerThreadCount(int workerThreadCount)
          Sets the number of worker threads used by this processor.
 void setWorkUnitFactory(WorkUnitFactory workUnitFactory)
          Sets a WorkUnitFactory instance for use by this processor.
 void setWorkUnitInputProducer(InputProducer inputProducer)
          Set an InputProducer instance.
 void start()
          Starts concurrently processing inputs returned by the InputProducer instance using WorkUnit instances returned by the WorkUnitFactory instance.
 
Methods inherited from interface chemaxon.util.concurrent.util.ConcurrentIterator
getNext, hasNext
 
Methods inherited from interface chemaxon.util.Cancelable
cancel, isCanceled
 

Method Detail

setWorkUnitFactory

void setWorkUnitFactory(WorkUnitFactory workUnitFactory)
Sets a WorkUnitFactory instance for use by this processor.

Parameters:
workUnitFactory - creates WorkUnit instances that will be used to concurrently process inputs returned by the InputProducer instance.

setWorkUnitInputProducer

void setWorkUnitInputProducer(InputProducer inputProducer)
Set an InputProducer instance.

Parameters:
inputProducer - returns inputs to be concurrently processed.

start

void start()
           throws edu.emory.mathcs.backport.java.util.concurrent.ExecutionException
Starts concurrently processing inputs returned by the InputProducer instance using WorkUnit instances returned by the WorkUnitFactory instance.

Throws:
edu.emory.mathcs.backport.java.util.concurrent.ExecutionException

cleanup

void cleanup(long joinTimeout)
             throws java.lang.InterruptedException,
                    edu.emory.mathcs.backport.java.util.concurrent.ExecutionException,
                    edu.emory.mathcs.backport.java.util.concurrent.TimeoutException
Awaits termination of worker threads executing on behalf of this processor and releases any resource this processor has reserved.

Parameters:
joinTimeout - specifies in milliseconds at most how long this method is allowed to await the termination of each the worker threads. '0' means don't wait at all. This parameter is relevant when the worker threads have been cancelled as a result of the processor having been cancelled either explicitly by the user or internally reacting on an execution error.
Throws:
java.lang.InterruptedException - if the current thread has been interrupted.
edu.emory.mathcs.backport.java.util.concurrent.ExecutionException - if any of the worker threads encountered an error during execution.
edu.emory.mathcs.backport.java.util.concurrent.TimeoutException

cleanup

void cleanup()
             throws java.lang.InterruptedException,
                    edu.emory.mathcs.backport.java.util.concurrent.ExecutionException,
                    edu.emory.mathcs.backport.java.util.concurrent.TimeoutException
Calls cleanup(long) with Long.MAX_VALUE.

Throws:
java.lang.InterruptedException
edu.emory.mathcs.backport.java.util.concurrent.ExecutionException
edu.emory.mathcs.backport.java.util.concurrent.TimeoutException

setWorkerThreadCount

void setWorkerThreadCount(int workerThreadCount)
Sets the number of worker threads used by this processor. The default is derived from the type of the WorkUnits being processed using WorkUnitManager.getConcurrencyDegree(edu.emory.mathcs.backport.java.util.concurrent.Callable).