public class BufferedIoOutputStream extends AbstractInnerCloseable implements IoOutputStream
IoOutputStream
capable of queuing write requestsAbstractCloseable.State
Modifier and Type | Field and Description |
---|---|
protected AtomicReference<IoWriteFutureImpl> |
currentWrite |
protected Object |
id |
protected IoOutputStream |
out |
protected Queue<IoWriteFutureImpl> |
writes |
closeFuture, lock, state
log
CLOSE_WAIT_TIMEOUT, DEFAULT_CLOSE_WAIT_TIMEOUT
Constructor and Description |
---|
BufferedIoOutputStream(Object id,
IoOutputStream out) |
Modifier and Type | Method and Description |
---|---|
Object |
getId() |
protected Closeable |
getInnerCloseable() |
protected void |
startWriting() |
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 Queue<IoWriteFutureImpl> writes
protected final AtomicReference<IoWriteFutureImpl> currentWrite
protected final Object id
public BufferedIoOutputStream(Object id, IoOutputStream out)
public Object getId()
public IoWriteFuture writePacket(Buffer buffer) throws 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 sentIOException
- if an error occurred when encoding sending the packetprotected void startWriting() throws IOException
IOException
protected Closeable getInnerCloseable()
getInnerCloseable
in class AbstractInnerCloseable
Copyright © 2008–2021 The Apache Software Foundation. All rights reserved.