public class BufferedIoOutputStream extends AbstractInnerCloseable implements IoOutputStream
IoOutputStream
capable of queuing write requestsAbstractCloseable.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, lock, state
log
CLOSE_WAIT_TIMEOUT, DEFAULT_CLOSE_WAIT_TIMEOUT
Constructor and Description |
---|
BufferedIoOutputStream(java.lang.Object id,
IoOutputStream out) |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
getId() |
protected Closeable |
getInnerCloseable() |
protected void |
startWriting() |
java.lang.String |
toString() |
IoWriteFuture |
writePacket(Buffer buffer)
Encode and send the given buffer.
|
doCloseGracefully, doCloseImmediately
addCloseFutureListener, builder, close, isClosed, isClosing, preClose, removeCloseFutureListener
getSimplifiedLogger
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 writePacket(Buffer buffer) throws java.io.IOException
PacketWriter
writePacket
in interface PacketWriter
buffer
- the buffer to encode and send. NOTE: the buffer must not be touched
until the returned write future is completed.IoWriteFuture
that can be used to check when the packet has actually been sentjava.io.IOException
- if an error occurred when encoding sending the packetprotected void startWriting() throws java.io.IOException
java.io.IOException
protected Closeable getInnerCloseable()
getInnerCloseable
in class AbstractInnerCloseable
public java.lang.String toString()
toString
in class java.lang.Object