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 setMaxOutputQueueSize(int size)
          Sets the maximum size of the output queue.
 void setWorkerThreadCount(int workerThreadCount)
          Sets the number of worker threads used by this processor.
 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

setMaxOutputQueueSize

void setMaxOutputQueueSize(int size)
Sets the maximum size of the output queue. Has to be called before start() is called. The default output queue size is: CPU core count * 100.

Parameters:
size - the maximum size of the output queue.
Since:
5.3

start

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

Throws:
java.util.concurrent.ExecutionException

cleanup

void cleanup(long joinTimeout)
             throws java.lang.InterruptedException,
                    java.util.concurrent.ExecutionException,
                    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.
java.util.concurrent.ExecutionException - if any of the worker threads encountered an error during execution.
java.util.concurrent.TimeoutException

cleanup

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

Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
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(java.util.concurrent.Callable).