T - The type of the objects that pose the "output" of the tasksEX - The exception type that the tasks may throwpublic class ObjectSequentializer<T,EX extends java.lang.Exception>
extends java.lang.Object
Consumer (or ConsumerWhichThrows) | Constructor and Description |
|---|
ObjectSequentializer(ConsumerWhichThrows<? super T,? extends EX> delegate,
java.util.concurrent.ExecutorService squadExecutor) |
| Modifier and Type | Method and Description |
|---|---|
void |
awaitCompletion()
Returns when all tasks that were previously submitted with
submit(ConsumerWhichThrows) have completed. |
void |
submit(ConsumerWhichThrows<? super ConsumerWhichThrows<? super T,? extends EX>,? extends java.lang.Exception> task)
Subjects written to the task's subject will be written to the
delegate after all subjects written by the
previously submitted tasks, and before the subjects of all tasks submitted afterwards. |
public ObjectSequentializer(ConsumerWhichThrows<? super T,? extends EX> delegate, java.util.concurrent.ExecutorService squadExecutor)
ObjectSequentializerpublic void submit(ConsumerWhichThrows<? super ConsumerWhichThrows<? super T,? extends EX>,? extends java.lang.Exception> task)
delegate after all subjects written by the
previously submitted tasks, and before the subjects of all tasks submitted afterwards.
Notice that when a task submits another task (the "subtask"), then the output of the subtask will appear
after the output of the task (and the output of all other tasks submitted in the meantime).
If you want to have the output of subtasks to be in the middle of the task's output, then you should
create a second ObjectSequentializer and await its completion.
public void awaitCompletion()
throws java.lang.InterruptedException,
java.util.concurrent.ExecutionException,
java.util.concurrent.CancellationException
submit(ConsumerWhichThrows) have completed.java.util.concurrent.CancellationException - One of the tasks was cancelledjava.util.concurrent.ExecutionException - One of the tasks threw an exceptionjava.lang.InterruptedException - The current thread was interrupted while waiting