public class AsyncByteStreamWriter extends AsyncAgent
The stream bytes are read from a ByteRingBuffer.
Note: The caller is responsible for opening and closing the stream as needed.
WhenReady,
AsyncAgent,
ByteRingBuffer| Constructor and Description |
|---|
AsyncByteStreamWriter(java.io.OutputStream outputStream,
ByteRingBuffer byteRingBuffer,
AsyncOptions asyncOptions)
Constructs a new AsyncByteStreamWriter instance to write to the given OutputStream
from the given
ByteRingBuffer. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
action()
"action" function that reads bytes from the ring buffer and writes them to the stream.
|
protected boolean |
done()
|
ByteRingBuffer |
getByteRingBuffer()
Returns the attached ring buffer where bytes will be read from.
|
java.io.OutputStream |
getOutputStream()
Returns the underlying OutputStream.
|
boolean |
isEOF()
Checks whether this writer has reached EOF of the byte ring buffer.
|
protected boolean |
ready()
"ready" predicate that returns true when bytes can be read from the ring buffer without blocking.
|
applyAsync, isIdle, setIdle, setIdleAndThrow, startApplyLoopAsyncpublic AsyncByteStreamWriter(java.io.OutputStream outputStream,
ByteRingBuffer byteRingBuffer,
AsyncOptions asyncOptions)
ByteRingBuffer.outputStream - An OutputStream to write to.byteRingBuffer - A ByteRingBuffer to read from.asyncOptions - AsyncOptions that will control all async operations on this instance.public java.io.OutputStream getOutputStream()
public ByteRingBuffer getByteRingBuffer()
public boolean isEOF()
protected boolean ready()
Notice that OutputStream, unlike InputStream, has no way to report how many bytes can be written without blocking.
ready in class AsyncAgentAsyncAgent.action().protected boolean done()
AsyncAgentWhenReady.startApplyLoopAsync(java.util.function.Predicate<S>, java.util.function.Predicate<S>, java.util.function.Function<S, R>, S).done in class AsyncAgentprotected void action()
action in class AsyncAgent