Top Description Fields Constructors Methods
io.netty5.channel.nio

public abstract Class AbstractNioChannel<P extends Channel, L extends SocketAddress, R extends SocketAddress>

extends AbstractChannel<P extends Channel, L extends SocketAddress, R extends SocketAddress>
Class Inheritance
Known Direct Subclasses
io.netty5.channel.nio.AbstractNioMessageChannel, io.netty5.channel.nio.AbstractNioByteChannel
Imports
io.netty5.buffer.Buffer, .BufferAllocator, .DefaultBufferAllocators, io.netty5.channel.ReadHandleFactory, .WriteHandleFactory, .AbstractChannel, .Channel, .ChannelException, .EventLoop, io.netty5.util.Resource, io.netty5.util.internal.logging.InternalLogger, .InternalLoggerFactory, java.io.IOException, java.net.SocketAddress, java.nio.channels.CancelledKeyException, .ClosedChannelException, .SelectableChannel, .SelectionKey, .Selector

Abstract base class for Channel implementations which use a Selector based approach.

Field Summary

Modifier and TypeField and Description
private final SelectableChannel
private static final InternalLogger
private final NioProcessor
private final int
private volatile SelectionKey

Constructor Summary

AccessConstructor and Description
protected
AbstractNioChannel(P
the parent Channel by which this instance was created. May be null
parent
,
EventLoop
the EventLoop to use for all I/O.
eventLoop
,
boolean
true if and only if the channel has the disconnect() operation that allows a user to disconnect and then call {
supportingDisconnect
,
ReadHandleFactory
the default ReadHandleFactory to use.
defaultReadHandleFactory
,
WriteHandleFactory
the WriteHandleFactory that is used by default.
defaultWriteHandleFactory
,
SelectableChannel
the underlying SelectableChannel on which it operates
ch
,
int
the ops to set to receive data from the SelectableChannel
readInterestOp
)

Create a new instance

Method Summary

Modifier and TypeMethod and Description
private void
protected final void
protected final void
protected final void
doRead(boolean
true if a read was already pending when read() was called.
wasReadPendingAlready
)

Implements abstract io.netty5.channel.AbstractChannel.doRead.

Schedule a read operation.
private void
private static BufferAllocator
public final boolean
isOpen()

Implements io.netty5.channel.Channel.isOpen.

Returns true if the Channel is open and may get active later
protected final boolean
isWriteFlushedScheduled()

Overrides io.netty5.channel.AbstractChannel.isWriteFlushedScheduled.

Returns true if flushed messages should not be tried to write when calling flush().
protected SelectableChannel
protected final Buffer

Returns:

Probably an off-heap copy of the given buffer.
newDirectBuffer
(Buffer
The buffer to copy.
buf
)

Allocates a new off-heap copy of the given buffer, unless the cost of doing so is too high.

protected final Buffer

Returns:

Probably an off-heap copy of the given buffer.
newDirectBuffer
(Resource<?> holder, Buffer
The buffer to copy.
buf
)

Allocates a new off-heap copy of the given buffer, unless the cost of doing so is too high.

pack-priv final NioProcessor
protected final SelectionKey
selectionKey()

Return the current SelectionKey or null if the underlying channel was not registered with the Selector yet.

protected final void
writeLoopComplete(boolean
true if all messages were written during the write loop, false otherwise.
allWritten
)

Overrides io.netty5.channel.AbstractChannel.writeLoopComplete.

Called once the write loop completed.
Inherited from io.netty5.channel.AbstractChannel:
bufferAllocatorcacheAddressescloseFuturecloseTransportcompareTodoBinddoConnectdoDisconnectdoFinishConnectdoReadNowdoShutdowndoWriteNowequalsexecutorfilterOutboundMessagefinishConnectgetExtendedOptiongetOptionhashCodeidisConnectPendingisExtendedOptionSupportedisOptionSupportedisReadPendingisRegisteredisSupportingDisconnectlocalAddresslocalAddress0newChannelPipelinenewSupportedIdentityOptionsSetparentpipelineprepareToClosereadBufferAllocatorreadHandlereadIfIsAutoReadreadLoopCompletereadNowremoteAddressremoteAddress0setExtendedOptionsetOptionshutdownReadSidetoStringvalidateEventLoopGroupvalidateFileRegionwritableByteswriteFlushedwriteFlushedNowwriteHandle

Field Detail

chback to summary
private final SelectableChannel ch
loggerback to summary
private static final InternalLogger logger

Hides io.netty5.channel.AbstractChannel.logger.

nioProcessorback to summary
private final NioProcessor nioProcessor
readInterestOpback to summary
private final int readInterestOp
selectionKeyback to summary
private volatile SelectionKey selectionKey

Constructor Detail

AbstractNioChannelback to summary
protected AbstractNioChannel(P parent, EventLoop eventLoop, boolean supportingDisconnect, ReadHandleFactory defaultReadHandleFactory, WriteHandleFactory defaultWriteHandleFactory, SelectableChannel ch, int readInterestOp)

Create a new instance

Parameters
parent:P

the parent Channel by which this instance was created. May be null

eventLoop:EventLoop

the EventLoop to use for all I/O.

supportingDisconnect:boolean

true if and only if the channel has the disconnect() operation that allows a user to disconnect and then call {

defaultReadHandleFactory:ReadHandleFactory

the default ReadHandleFactory to use.

defaultWriteHandleFactory:WriteHandleFactory

the WriteHandleFactory that is used by default.

ch:SelectableChannel

the underlying SelectableChannel on which it operates

readInterestOp:int

the ops to set to receive data from the SelectableChannel

Method Detail

closeTransportNowback to summary
private void closeTransportNow()
doClearScheduledReadback to summary
protected final void doClearScheduledRead()

Overrides io.netty5.channel.AbstractChannel.doClearScheduledRead.

Doc from io.netty5.channel.AbstractChannel.doClearScheduledRead.

Clear any previous scheduled read. By default, this method does nothing but implementations might override it to add extra logic.

Annotations
@Override
doCloseback to summary
protected final void doClose() throws Exception

Implements abstract io.netty5.channel.AbstractChannel.doClose.

Doc from io.netty5.channel.AbstractChannel.doClose.

Close the Channel

Annotations
@Override
Exceptions
Exception:
thrown on error.
doReadback to summary
protected final void doRead(boolean wasReadPendingAlready)

Implements abstract io.netty5.channel.AbstractChannel.doRead.

Doc from io.netty5.channel.AbstractChannel.doRead.

Schedule a read operation.

Parameters
wasReadPendingAlready:boolean

true if a read was already pending when read() was called.

Annotations
@Override
finishConnectNowback to summary
private void finishConnectNow()
ioBufferAllocatorback to summary
private static BufferAllocator ioBufferAllocator(BufferAllocator bufferAllocator)
isOpenback to summary
public final boolean isOpen()

Implements io.netty5.channel.Channel.isOpen.

Doc from io.netty5.channel.Channel.isOpen.

Returns true if the Channel is open and may get active later

Annotations
@Override
isWriteFlushedScheduledback to summary
protected final boolean isWriteFlushedScheduled()

Overrides io.netty5.channel.AbstractChannel.isWriteFlushedScheduled.

Doc from io.netty5.channel.AbstractChannel.isWriteFlushedScheduled.

Returns true if flushed messages should not be tried to write when calling flush(). Instead these will be written once writeFlushedNow() is called, which is typically done once the underlying transport becomes writable again.

Returns:boolean

true if write will be done later on by calling writeFlushedNow(), false otherwise.

Annotations
@Override
javaChannelback to summary
protected SelectableChannel javaChannel()
newDirectBufferback to summary
protected final Buffer newDirectBuffer(Buffer buf)

Allocates a new off-heap copy of the given buffer, unless the cost of doing so is too high. The given buffer is closed if a copy is created, or returned directly.

Parameters
buf:Buffer

The buffer to copy.

Returns:Buffer

Probably an off-heap copy of the given buffer.

newDirectBufferback to summary
protected final Buffer newDirectBuffer(Resource<?> holder, Buffer buf)

Allocates a new off-heap copy of the given buffer, unless the cost of doing so is too high. The given holder is closed regardless.

Parameters
buf:Buffer

The buffer to copy.

Returns:Buffer

Probably an off-heap copy of the given buffer.

nioProcessorback to summary
pack-priv final NioProcessor nioProcessor()
selectionKeyback to summary
protected final SelectionKey selectionKey()

Return the current SelectionKey or null if the underlying channel was not registered with the Selector yet.

writeLoopCompleteback to summary
protected final void writeLoopComplete(boolean allWritten)

Overrides io.netty5.channel.AbstractChannel.writeLoopComplete.

Doc from io.netty5.channel.AbstractChannel.writeLoopComplete.

Called once the write loop completed. Subclasses might override this method for custom logic but should also call super.

Parameters
allWritten:boolean

true if all messages were written during the write loop, false otherwise.

Annotations
@Override