public interface AsyncWritableChannel
extends java.nio.channels.Channel
Modifier and Type | Method and Description |
---|---|
default java.util.concurrent.Future<java.lang.Long> |
write(io.netty.buffer.ByteBuf src,
Callback<java.lang.Long> callback)
Write data in
src to the channel and the callback will be invoked once the write succeeds or fails. |
java.util.concurrent.Future<java.lang.Long> |
write(java.nio.ByteBuffer src,
Callback<java.lang.Long> callback)
The data in
src will be eventually written to the channel and the callback will be invoked once the
write succeeds/fails. |
java.util.concurrent.Future<java.lang.Long> write(java.nio.ByteBuffer src, Callback<java.lang.Long> callback)
src
will be eventually written to the channel and the callback
will be invoked once the
write succeeds/fails. The callback
and the future returned will contain the bytes written
(that should be equal to src.remaining()
at the time of invocation if there were no exceptions) on success
or failure. If the write failed, they will also contain the exception that caused the failure.
Every single write is guaranteed to be acknowledged as either succeeded or failed even if the channel is closed.
Further, writes will be acknowledged in the same order that they were received.
src
can be reused only after the callback
is invoked (or after future.get()
returns).
Concurrent write calls may result in unexpected behavior.src
- the data that needs to be written to the channel.callback
- the Callback
that will be invoked once the write succeeds/fails. This can be null.Future
that will eventually contain the result of the write operation (the number of bytes
written).default java.util.concurrent.Future<java.lang.Long> write(io.netty.buffer.ByteBuf src, Callback<java.lang.Long> callback)
src
to the channel and the callback
will be invoked once the write succeeds or fails.
This method is the counterpart for ByteBuf
. It shares the same guarantee as the write(ByteBuffer, Callback)
.
Whoever implements this interface, shouldn't release the src
. If releasing is expected after finishing writing
to channel, please release this ByteBuf
in the callback method.src
- The data taht needs to be written to the channel.callback
- The Callback
that will be invoked once the write succeeds/fails. This can be null.Future
that will eventually contain the result of the write operation (the number of bytes
written).