public class BufferedIoOutputStream extends AbstractInnerCloseable implements IoOutputStream
IoOutputStream
capable of queuing write requests.AbstractCloseable.State
Modifier and Type | Field and Description |
---|---|
protected java.util.concurrent.atomic.AtomicReference<IoWriteFutureImpl> |
currentWrite |
protected java.lang.Object |
id |
protected IoOutputStream |
out |
protected java.util.Queue<IoWriteFutureImpl> |
writes |
closeFuture, futureLock, state
log
Constructor and Description |
---|
BufferedIoOutputStream(java.lang.Object id,
IoOutputStream out) |
Modifier and Type | Method and Description |
---|---|
protected void |
finishWrite(IoWriteFutureImpl future) |
java.lang.Object |
getId() |
protected Closeable |
getInnerCloseable() |
protected void |
startWriting() |
java.lang.String |
toString() |
IoWriteFuture |
writeBuffer(Buffer buffer)
Write the given buffer.
|
doCloseGracefully, doCloseImmediately
addCloseFutureListener, builder, close, getFutureLock, isClosed, isClosing, preClose, removeCloseFutureListener
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warn
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addCloseFutureListener, close, close, close, getMaxCloseWaitTime, isClosed, isClosing, isOpen, removeCloseFutureListener
protected final IoOutputStream out
protected final java.util.Queue<IoWriteFutureImpl> writes
protected final java.util.concurrent.atomic.AtomicReference<IoWriteFutureImpl> currentWrite
protected final java.lang.Object id
public BufferedIoOutputStream(java.lang.Object id, IoOutputStream out)
public java.lang.Object getId()
public IoWriteFuture writeBuffer(Buffer buffer) throws java.io.IOException
IoOutputStream
writeBuffer
in interface IoOutputStream
buffer
- the data to write. NOTE: the buffer must not be touched until the returned write
future is completed.IoWriteFuture
that can be used to check when the data has actually been written.java.io.IOException
- if an error occurred when writing the dataprotected void startWriting() throws java.io.IOException
java.io.IOException
protected void finishWrite(IoWriteFutureImpl future)
protected Closeable getInnerCloseable()
getInnerCloseable
in class AbstractInnerCloseable
public java.lang.String toString()
toString
in class java.lang.Object