- java.lang.Object
-
- io.netty5.channel.AbstractChannel.WriteSink
-
- Enclosing class:
- AbstractChannel<P extends Channel,L extends SocketAddress,R extends SocketAddress>
protected final class AbstractChannel.WriteSink extends Object
Sink that will be used by#doWriteNow(WriteSink)implementations.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcomplete(long attemptedBytesWrite, long actualBytesWrite, int messagesWritten, boolean mightContinueWriting)Notify of the last write operation and its result.voidcomplete(long attemptedBytesWrite, Throwable cause, boolean mightContinueWriting)Notify of the last write operation and its result.ObjectcurrentFlushedMessage()Return the current message that should be written.longestimatedMaxBytesPerGatheringWrite()Return the estimated maximum number of bytes that can be written with one gathering write operation.voidforEachFlushedMessage(Predicate<Object> processor)CallPredicate.test(Object)for each message that is flushed untilPredicate.test(Object)returnsfalseor there are no more flushed messages.intnumFlushedMessages()The number of flushed messages that are ready to be written.intupdateBufferReaderOffsets(long writtenBytes)Update theBuffer.readerOffset()of each buffer and return the number of completely writtenBuffers.
-
-
-
Method Detail
-
updateBufferReaderOffsets
public int updateBufferReaderOffsets(long writtenBytes)
Update theBuffer.readerOffset()of each buffer and return the number of completely writtenBuffers.- Parameters:
writtenBytes- the number of written bytes.- Returns:
- the number of completely written buffers.
-
estimatedMaxBytesPerGatheringWrite
public long estimatedMaxBytesPerGatheringWrite()
Return the estimated maximum number of bytes that can be written with one gathering write operation.- Returns:
- number of bytes.
-
numFlushedMessages
public int numFlushedMessages()
The number of flushed messages that are ready to be written. The messages can be accessed by either callingcurrentFlushedMessage()orforEachFlushedMessage(Predicate).- Returns:
- the number of messages.
-
currentFlushedMessage
public Object currentFlushedMessage()
Return the current message that should be written.- Returns:
- the first flushed message.
-
forEachFlushedMessage
public void forEachFlushedMessage(Predicate<Object> processor)
CallPredicate.test(Object)for each message that is flushed untilPredicate.test(Object)returnsfalseor there are no more flushed messages.- Parameters:
processor- theFunctionto use.- Throws:
IllegalStateException- if called aftercomplete(long, long, int, boolean)orcomplete(long, Throwable, boolean)was called.
-
complete
public void complete(long attemptedBytesWrite, long actualBytesWrite, int messagesWritten, boolean mightContinueWriting)Notify of the last write operation and its result.- Parameters:
attemptedBytesWrite- The number of bytes the write operation did attempt to write.actualBytesWrite- The number of bytes from the previous write operation. This may be negative if a write error occurs.messagesWritten- The number of written messages, this can never be greater thannumFlushedMessages().mightContinueWriting-trueif the write loop might continue writing messages,falseotherwise- Throws:
IllegalStateException- if called aftercomplete(long, long, int, boolean)orcomplete(long, Throwable, boolean)was called.
-
complete
public void complete(long attemptedBytesWrite, Throwable cause, boolean mightContinueWriting)Notify of the last write operation and its result.- Parameters:
attemptedBytesWrite- The number of bytes the write operation did attempt to write.cause- The error that happened during the write operation and can be recovered.mightContinueWriting-trueif the write loop might continue writing messages,falseotherwise.- Throws:
IllegalStateException- if called aftercomplete(long, long, int, boolean)orcomplete(long, Throwable, boolean)was called.
-
-