Module io.netty5.transport
Package io.netty5.channel.nio
Class AbstractNioChannel<P extends Channel,L extends SocketAddress,R extends SocketAddress>
- java.lang.Object
-
- io.netty5.util.DefaultAttributeMap
-
- io.netty5.channel.AbstractChannel<P,L,R>
-
- io.netty5.channel.nio.AbstractNioChannel<P,L,R>
-
- All Implemented Interfaces:
Channel
,ChannelOutboundInvoker
,IoHandle
,AttributeMap
,FuturePromiseFactory
,Comparable<Channel>
- Direct Known Subclasses:
AbstractNioByteChannel
,AbstractNioMessageChannel
public abstract class AbstractNioChannel<P extends Channel,L extends SocketAddress,R extends SocketAddress> extends AbstractChannel<P,L,R>
Abstract base class forChannel
implementations which use a Selector based approach.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class io.netty5.channel.AbstractChannel
AbstractChannel.DefaultAbstractChannelPipeline
-
-
Field Summary
Fields Modifier and Type Field Description protected int
readInterestOp
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractNioChannel(P parent, EventLoop eventLoop, ChannelMetadata metadata, RecvBufferAllocator defaultRecvAllocator, SelectableChannel ch, int readInterestOp)
Create a new instance
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
clearReadPending()
Set read pending tofalse
.protected void
doBeginRead()
Schedule a read operation.protected void
doClose()
Close theChannel
boolean
isOpen()
Returnstrue
if theChannel
is open and may get active laterprotected boolean
isReadPending()
Deprecated.No longer supported.protected SelectableChannel
javaChannel()
protected Buffer
newDirectBuffer(Buffer buf)
Allocates a new off-heap copy of the given buffer, unless the cost of doing so is too high.protected 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.protected abstract void
readNow()
protected void
removeReadOp()
protected SelectionKey
selectionKey()
Return the currentSelectionKey
ornull
if the underlying channel was not registered with theSelector
yet.protected void
setReadPending(boolean readPending)
Deprecated.UseclearReadPending()
if appropriate instead.protected void
writeFlushed()
Write previous flushed messages.-
Methods inherited from class io.netty5.channel.AbstractChannel
annotateConnectException, assertEventLoop, autoReadCleared, bufferAllocator, cacheAddresses, closeForciblyTransport, closeFuture, closeIfClosed, closeTransport, compareTo, deregisterTransport, doBind, doConnect, doDisconnect, doFinishConnect, doShutdown, doWrite, ensureOpen, equals, executor, filterOutboundMessage, finishConnect, fireChannelActiveIfNotActiveBefore, getExtendedOption, getMaxMessagesPerWrite, getOption, getWriteSpinCount, handleWriteError, hashCode, id, isAllowHalfClosure, isAutoRead, isConnectPending, isExtendedOptionSupported, isOptionSupported, isRegistered, localAddress, localAddress0, metadata, newChannelPipeline, newSupportedIdentityOptionsSet, outboundBuffer, parent, pipeline, prepareToClose, readIfIsAutoRead, recvBufAllocHandle, remoteAddress, remoteAddress0, runAfterTransportAction, safeSetFailure, safeSetSuccess, setBufferAllocator, setExtendedOption, setOption, shutdownTransport, toString, validate, validateEventLoopGroup, validateFileRegion, writableBytes
-
Methods inherited from class io.netty5.util.DefaultAttributeMap
attr, hasAttr
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.netty5.util.AttributeMap
attr, hasAttr
-
Methods inherited from interface io.netty5.channel.Channel
bind, close, connect, connect, deregister, disconnect, flush, isActive, isShutdown, isWritable, read, register, sendOutboundEvent, shutdown, write, writeAndFlush
-
Methods inherited from interface io.netty5.channel.ChannelOutboundInvoker
newFailedFuture, newPromise, newSucceededFuture, newSucceededFuture
-
-
-
-
Constructor Detail
-
AbstractNioChannel
protected AbstractNioChannel(P parent, EventLoop eventLoop, ChannelMetadata metadata, RecvBufferAllocator defaultRecvAllocator, SelectableChannel ch, int readInterestOp)
Create a new instance- Parameters:
parent
- the parentChannel
by which this instance was created. May benull
eventLoop
- theEventLoop
to use for all I/O.metadata
- theChannelMetadata
to use.defaultRecvAllocator
- the defaultRecvBufferAllocator
to use.ch
- the underlyingSelectableChannel
on which it operatesreadInterestOp
- the ops to set to receive data from theSelectableChannel
-
-
Method Detail
-
isOpen
public boolean isOpen()
Description copied from interface:Channel
Returnstrue
if theChannel
is open and may get active later
-
javaChannel
protected SelectableChannel javaChannel()
-
selectionKey
protected SelectionKey selectionKey()
Return the currentSelectionKey
ornull
if the underlying channel was not registered with theSelector
yet.
-
isReadPending
@Deprecated protected boolean isReadPending()
Deprecated.No longer supported. No longer supported.
-
setReadPending
@Deprecated protected void setReadPending(boolean readPending)
Deprecated.UseclearReadPending()
if appropriate instead. No longer supported.
-
clearReadPending
protected final void clearReadPending()
Set read pending tofalse
.
-
removeReadOp
protected final void removeReadOp()
-
writeFlushed
protected final void writeFlushed()
Description copied from class:AbstractChannel
Write previous flushed messages.- Overrides:
writeFlushed
in classAbstractChannel<P extends Channel,L extends SocketAddress,R extends SocketAddress>
-
doBeginRead
protected void doBeginRead() throws Exception
Description copied from class:AbstractChannel
Schedule a read operation.- Specified by:
doBeginRead
in classAbstractChannel<P extends Channel,L extends SocketAddress,R extends SocketAddress>
- Throws:
Exception
-
doClose
protected void doClose() throws Exception
Description copied from class:AbstractChannel
Close theChannel
- Specified by:
doClose
in classAbstractChannel<P extends Channel,L extends SocketAddress,R extends SocketAddress>
- Throws:
Exception
-
newDirectBuffer
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
- The buffer to copy.- Returns:
- Probably an off-heap copy of the given buffer.
-
newDirectBuffer
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
- The buffer to copy.- Returns:
- Probably an off-heap copy of the given buffer.
-
readNow
protected abstract void readNow()
-
-