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 Throwable> extends Object
Consumer
(or ConsumerWhichThrows
) Constructor and Description |
---|
ObjectSequentializer(ConsumerWhichThrows<? super T,? extends EX> delegate,
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 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, ExecutorService squadExecutor)
ObjectSequentializer
public void submit(ConsumerWhichThrows<? super ConsumerWhichThrows<? super T,? extends EX>,? extends 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 InterruptedException, ExecutionException, CancellationException
submit(ConsumerWhichThrows)
have completed.CancellationException
- One of the tasks was cancelledExecutionException
- One of the tasks threw an exceptionInterruptedException
- The current thread was interrupted while waitingCopyright © 2018 Arno Unkrig. All rights reserved.