public class ByteStreamSequentializer
extends java.lang.Object
OutputStream | Constructor and Description |
|---|
ByteStreamSequentializer(java.io.OutputStream delegate,
java.util.concurrent.ExecutorService squadExecutor) |
| Modifier and Type | Method and Description |
|---|---|
void |
awaitCompletion()
Returns when all tasks that were previously submitted with
submit(Consumer) and submit(ConsumerWhichThrows) have completed. |
void |
submit(Consumer<? super java.io.OutputStream> task)
Data written to the task's subject will be written to the
delegate after all data written by the
previously submitted tasks, and before the data written by all tasks submitted afterwards. |
<EX extends java.lang.Throwable> |
submit(ConsumerWhichThrows<? super java.io.OutputStream,EX> task) |
public ByteStreamSequentializer(java.io.OutputStream delegate,
java.util.concurrent.ExecutorService squadExecutor)
ByteStreamSequentializerpublic void submit(Consumer<? super java.io.OutputStream> task)
delegate after all data written by the
previously submitted tasks, and before the data written by all tasks submitted afterwards.
Notice that when a tasks submits another task (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 ByteStreamSequentializer and await its completion.
public <EX extends java.lang.Throwable> void submit(ConsumerWhichThrows<? super java.io.OutputStream,EX> task)
submit(Consumer)public void awaitCompletion()
throws java.lang.InterruptedException,
java.util.concurrent.ExecutionException,
java.util.concurrent.CancellationException,
java.io.IOException
submit(Consumer) and 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 waitingjava.io.IOException