de.unkrig.commons.util
Class WyeConsumer<T,EX extends java.lang.Exception>

java.lang.Object
  extended by de.unkrig.commons.util.WyeConsumer<T,EX>
Type Parameters:
T - The type of the subjects
EX - The exception that the producers may throw
All Implemented Interfaces:
RunnableWhichThrows<EX>

public class WyeConsumer<T,EX extends java.lang.Exception>
extends java.lang.Object
implements RunnableWhichThrows<EX>

Collects the subjects produced by several producers and forwards them to one consumer in the right order. This is useful for parallelized tasks from which the results must be collected and be brought into the original order.

See Also:
run()

Constructor Summary
WyeConsumer(ConsumerWhichThrows<T,EX> target)
           
 
Method Summary
 Consumer<T> newConsumer(int capacity)
           
 void run()
          Copies the subjects that are sent to the Consumer that was returned by the first call to newConsumer(int) up to, but not including, the first null reference, to the target consumer, then the objects that are sent to the Consumer that was returned by the second call to newConsumer(int), and so forth.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WyeConsumer

public WyeConsumer(ConsumerWhichThrows<T,EX> target)
See Also:
run()
Method Detail

newConsumer

public Consumer<T> newConsumer(int capacity)
See Also:
run()

run

public void run()
         throws EX extends java.lang.Exception
Copies the subjects that are sent to the Consumer that was returned by the first call to newConsumer(int) up to, but not including, the first null reference, to the target consumer, then the objects that are sent to the Consumer that was returned by the second call to newConsumer(int), and so forth.

Specified by:
run in interface RunnableWhichThrows<EX extends java.lang.Exception>
Throws:
EX extends java.lang.Exception