chemaxon.util.concurrent.marvin
Class ReusableInputProducer

java.lang.Object
  extended by chemaxon.util.concurrent.marvin.ReusableInputProducer
All Implemented Interfaces:
InputProducer, chemaxon.util.concurrent.util.ConcurrentIterator

public class ReusableInputProducer
extends java.lang.Object
implements InputProducer

Input producer that provides reusable input. The input objects are stored in a queue, returned one-by-one by getNext() and should be returned by the caller by reuse(java.lang.Object) - then the input object is again added to the queue and can be accessed by getNext(). This input producer can be used to distribute resources, calculation performer objects (e.g. plugins).

Since:
Marvin 5.0
Author:
Nora Mate

Constructor Summary
ReusableInputProducer(java.lang.Object[] inputs)
          Constructor.
 
Method Summary
protected  java.lang.Object createInput()
           
 java.lang.Object getNext()
          Returns the next input object.
 boolean hasNext()
          Returns true.
 void reuse(java.lang.Object input)
          Puts an input object into the input queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReusableInputProducer

public ReusableInputProducer(java.lang.Object[] inputs)
Constructor. Sets the input objects.

Parameters:
inputs - the input objects
Method Detail

reuse

public void reuse(java.lang.Object input)
Puts an input object into the input queue. Called by work units after the input object is no longer needed.

Parameters:
input - the input object

hasNext

public boolean hasNext()
                throws java.lang.InterruptedException,
                       java.util.concurrent.ExecutionException
Returns true.

Specified by:
hasNext in interface chemaxon.util.concurrent.util.ConcurrentIterator
Returns:
true
Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException

getNext

public java.lang.Object getNext()
                         throws java.lang.InterruptedException,
                                java.util.concurrent.ExecutionException
Returns the next input object.

Specified by:
getNext in interface chemaxon.util.concurrent.util.ConcurrentIterator
Returns:
the next input object
Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException

createInput

protected java.lang.Object createInput()