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,io.netty5.util.AttributeMap,io.netty5.util.concurrent.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 forChannelimplementations which use a Selector based approach.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class io.netty5.channel.AbstractChannel
AbstractChannel.DefaultAbstractChannelPipeline, AbstractChannel.ReadSink, AbstractChannel.WriteSink
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractNioChannel(P parent, EventLoop eventLoop, boolean supportingDisconnect, ReadHandleFactory defaultReadHandleFactory, WriteHandleFactory defaultWriteHandleFactory, SelectableChannel ch, int readInterestOp)Create a new instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddoClearScheduledRead()Clear any previous scheduled read.protected voiddoClose()Close theChannelprotected voiddoRead(boolean wasReadPendingAlready)Schedule a read operation.booleanisOpen()Returnstrueif theChannelis open and may get active laterprotected booleanisWriteFlushedScheduled()Returnstrueif flushed messages should not be tried to write when callingChannel.flush().protected SelectableChanneljavaChannel()protected io.netty5.buffer.BuffernewDirectBuffer(io.netty5.buffer.Buffer buf)Allocates a new off-heap copy of the given buffer, unless the cost of doing so is too high.protected io.netty5.buffer.BuffernewDirectBuffer(io.netty5.util.Resource<?> holder, io.netty5.buffer.Buffer buf)Allocates a new off-heap copy of the given buffer, unless the cost of doing so is too high.protected SelectionKeyselectionKey()Return the currentSelectionKeyornullif the underlying channel was not registered with theSelectoryet.protected voidwriteLoopComplete(boolean allWritten)Called once the write loop completed.-
Methods inherited from class io.netty5.channel.AbstractChannel
bufferAllocator, cacheAddresses, closeFuture, closeTransport, compareTo, doBind, doConnect, doDisconnect, doFinishConnect, doReadNow, doShutdown, doWriteNow, equals, executor, filterOutboundMessage, finishConnect, getExtendedOption, getOption, hashCode, id, isConnectPending, isExtendedOptionSupported, isOptionSupported, isReadPending, isRegistered, isSupportingDisconnect, localAddress, localAddress0, newChannelPipeline, newSupportedIdentityOptionsSet, parent, pipeline, prepareToClose, readBufferAllocator, readHandle, readIfIsAutoRead, readLoopComplete, readNow, remoteAddress, remoteAddress0, setExtendedOption, setOption, shutdownReadSide, toString, validateEventLoopGroup, validateFileRegion, writableBytes, writeFlushed, writeFlushedNow, writeHandle
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.netty5.channel.Channel
bind, close, connect, connect, deregister, disconnect, flush, isActive, isShutdown, isWritable, read, 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, boolean supportingDisconnect, ReadHandleFactory defaultReadHandleFactory, WriteHandleFactory defaultWriteHandleFactory, SelectableChannel ch, int readInterestOp)
Create a new instance
-
-
Method Detail
-
isOpen
public final boolean isOpen()
Description copied from interface:ChannelReturnstrueif theChannelis open and may get active later
-
javaChannel
protected SelectableChannel javaChannel()
-
selectionKey
protected final SelectionKey selectionKey()
Return the currentSelectionKeyornullif the underlying channel was not registered with theSelectoryet.
-
doClearScheduledRead
protected final void doClearScheduledRead()
Description copied from class:AbstractChannelClear any previous scheduled read. By default, this method does nothing but implementations might override it to add extra logic.- Overrides:
doClearScheduledReadin classAbstractChannel<P extends Channel,L extends SocketAddress,R extends SocketAddress>
-
isWriteFlushedScheduled
protected final boolean isWriteFlushedScheduled()
Description copied from class:AbstractChannelReturnstrueif flushed messages should not be tried to write when callingChannel.flush(). Instead these will be written onceAbstractChannel.writeFlushedNow()is called, which is typically done once the underlying transport becomes writable again.- Overrides:
isWriteFlushedScheduledin classAbstractChannel<P extends Channel,L extends SocketAddress,R extends SocketAddress>- Returns:
trueif write will be done later on by callingAbstractChannel.writeFlushedNow(),falseotherwise.
-
doRead
protected final void doRead(boolean wasReadPendingAlready)
Description copied from class:AbstractChannelSchedule a read operation.- Specified by:
doReadin classAbstractChannel<P extends Channel,L extends SocketAddress,R extends SocketAddress>- Parameters:
wasReadPendingAlready-trueif a read was already pending whenChannel.read()was called.
-
doClose
protected final void doClose() throws ExceptionDescription copied from class:AbstractChannelClose theChannel- Specified by:
doClosein classAbstractChannel<P extends Channel,L extends SocketAddress,R extends SocketAddress>- Throws:
Exception- thrown on error.
-
newDirectBuffer
protected final io.netty5.buffer.Buffer newDirectBuffer(io.netty5.buffer.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 io.netty5.buffer.Buffer newDirectBuffer(io.netty5.util.Resource<?> holder, io.netty5.buffer.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.
-
writeLoopComplete
protected final void writeLoopComplete(boolean allWritten)
Description copied from class:AbstractChannelCalled once the write loop completed. Subclasses might override this method for custom logic but should also call super.- Overrides:
writeLoopCompletein classAbstractChannel<P extends Channel,L extends SocketAddress,R extends SocketAddress>- Parameters:
allWritten-trueif all messages were written during the write loop,falseotherwise.
-
-