Package io.netty.channel
Class AbstractChannel.AbstractUnsafe
java.lang.Object
io.netty.channel.AbstractChannel.AbstractUnsafe
- All Implemented Interfaces:
Channel.Unsafe
- Direct Known Subclasses:
AbstractEpollChannel.AbstractEpollUnsafe
,AbstractKQueueChannel.AbstractKQueueUnsafe
,AbstractNioChannel.AbstractNioUnsafe
,AbstractOioChannel.DefaultOioUnsafe
,AbstractServerChannel.DefaultServerUnsafe
,EmbeddedChannel.EmbeddedUnsafe
,FailedChannel.FailedChannelUnsafe
,LocalChannel.LocalUnsafe
- Enclosing class:
AbstractChannel
Channel.Unsafe
implementation which sub-classes must extend and use.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private boolean
true if the channel has never been registered, false otherwiseprivate ChannelOutboundBuffer
private RecvByteBufAllocator.Handle
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final Throwable
annotateConnectException
(Throwable cause, SocketAddress remoteAddress) Appends the remote address to the message of the exceptions caused by connection attempt failure.private void
final void
Schedules a read operation that fills the inbound buffer of the firstChannelInboundHandler
in theChannelPipeline
.final void
bind
(SocketAddress localAddress, ChannelPromise promise) void
close
(ChannelPromise promise) Close theChannel
of theChannelPromise
and notify theChannelPromise
once the operation was complete.private void
close
(ChannelPromise promise, Throwable cause, ClosedChannelException closeCause, boolean notify) final void
Closes theChannel
immediately without firing any events.protected final void
private void
closeOutboundBufferForShutdown
(ChannelPipeline pipeline, ChannelOutboundBuffer buffer, Throwable cause) final void
deregister
(ChannelPromise promise) Deregister theChannel
of theChannelPromise
fromEventLoop
and notify theChannelPromise
once the operation was complete.private void
deregister
(ChannelPromise promise, boolean fireChannelInactive) final void
disconnect
(ChannelPromise promise) Disconnect theChannel
of theChannelFuture
and notify theChannelPromise
once the operation was complete.private void
doClose0
(ChannelPromise promise) protected final boolean
ensureOpen
(ChannelPromise promise) private void
fireChannelInactiveAndDeregister
(boolean wasActive) final void
flush()
Flush out all write operations scheduled viaChannel.Unsafe.write(Object, ChannelPromise)
.protected void
flush0()
protected final void
private void
invokeLater
(Runnable task) final SocketAddress
Return theSocketAddress
to which is bound local ornull
if none.private ClosedChannelException
newClosedChannelException
(Throwable cause, String method) final ChannelOutboundBuffer
Returns theChannelOutboundBuffer
of theChannel
where the pending write requests are stored.protected Executor
Prepares to close theChannel
.Return the assignedRecvByteBufAllocator.Handle
which will be used to allocateByteBuf
's when receiving data.final void
register
(EventLoop eventLoop, ChannelPromise promise) Register theChannel
of theChannelPromise
and notify theChannelFuture
once the registration was complete.private void
register0
(ChannelPromise promise) final SocketAddress
Return theSocketAddress
to which is bound remote ornull
if none is bound yet.protected final void
safeSetFailure
(ChannelPromise promise, Throwable cause) Marks the specifiedpromise
as failure.protected final void
safeSetSuccess
(ChannelPromise promise) Marks the specifiedpromise
as success.final void
shutdownOutput
(ChannelPromise promise) Shutdown the output portion of the correspondingChannel
.private void
shutdownOutput
(ChannelPromise promise, Throwable cause) Shutdown the output portion of the correspondingChannel
.final ChannelPromise
Return a special ChannelPromise which can be reused and passed to the operations inChannel.Unsafe
.final void
write
(Object msg, ChannelPromise promise) Schedules a write operation.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.netty.channel.Channel.Unsafe
connect
-
Field Details
-
outboundBuffer
-
recvHandle
-
inFlush0
private boolean inFlush0 -
neverRegistered
private boolean neverRegisteredtrue if the channel has never been registered, false otherwise
-
-
Constructor Details
-
AbstractUnsafe
protected AbstractUnsafe()
-
-
Method Details
-
assertEventLoop
private void assertEventLoop() -
recvBufAllocHandle
Description copied from interface:Channel.Unsafe
Return the assignedRecvByteBufAllocator.Handle
which will be used to allocateByteBuf
's when receiving data.- Specified by:
recvBufAllocHandle
in interfaceChannel.Unsafe
-
outboundBuffer
Description copied from interface:Channel.Unsafe
Returns theChannelOutboundBuffer
of theChannel
where the pending write requests are stored.- Specified by:
outboundBuffer
in interfaceChannel.Unsafe
-
localAddress
Description copied from interface:Channel.Unsafe
Return theSocketAddress
to which is bound local ornull
if none.- Specified by:
localAddress
in interfaceChannel.Unsafe
-
remoteAddress
Description copied from interface:Channel.Unsafe
Return theSocketAddress
to which is bound remote ornull
if none is bound yet.- Specified by:
remoteAddress
in interfaceChannel.Unsafe
-
register
Description copied from interface:Channel.Unsafe
Register theChannel
of theChannelPromise
and notify theChannelFuture
once the registration was complete.- Specified by:
register
in interfaceChannel.Unsafe
-
register0
-
bind
Description copied from interface:Channel.Unsafe
- Specified by:
bind
in interfaceChannel.Unsafe
-
disconnect
Description copied from interface:Channel.Unsafe
Disconnect theChannel
of theChannelFuture
and notify theChannelPromise
once the operation was complete.- Specified by:
disconnect
in interfaceChannel.Unsafe
-
close
Description copied from interface:Channel.Unsafe
Close theChannel
of theChannelPromise
and notify theChannelPromise
once the operation was complete.- Specified by:
close
in interfaceChannel.Unsafe
-
shutdownOutput
Shutdown the output portion of the correspondingChannel
. For example this will clean up theChannelOutboundBuffer
and not allow any more writes. -
shutdownOutput
Shutdown the output portion of the correspondingChannel
. For example this will clean up theChannelOutboundBuffer
and not allow any more writes.- Parameters:
cause
- The cause which may provide rational for the shutdown.
-
closeOutboundBufferForShutdown
private void closeOutboundBufferForShutdown(ChannelPipeline pipeline, ChannelOutboundBuffer buffer, Throwable cause) -
close
private void close(ChannelPromise promise, Throwable cause, ClosedChannelException closeCause, boolean notify) -
doClose0
-
fireChannelInactiveAndDeregister
private void fireChannelInactiveAndDeregister(boolean wasActive) -
closeForcibly
public final void closeForcibly()Description copied from interface:Channel.Unsafe
Closes theChannel
immediately without firing any events. Probably only useful when registration attempt failed.- Specified by:
closeForcibly
in interfaceChannel.Unsafe
-
deregister
Description copied from interface:Channel.Unsafe
Deregister theChannel
of theChannelPromise
fromEventLoop
and notify theChannelPromise
once the operation was complete.- Specified by:
deregister
in interfaceChannel.Unsafe
-
deregister
-
beginRead
public final void beginRead()Description copied from interface:Channel.Unsafe
Schedules a read operation that fills the inbound buffer of the firstChannelInboundHandler
in theChannelPipeline
. If there's already a pending read operation, this method does nothing.- Specified by:
beginRead
in interfaceChannel.Unsafe
-
write
Description copied from interface:Channel.Unsafe
Schedules a write operation.- Specified by:
write
in interfaceChannel.Unsafe
-
flush
public final void flush()Description copied from interface:Channel.Unsafe
Flush out all write operations scheduled viaChannel.Unsafe.write(Object, ChannelPromise)
.- Specified by:
flush
in interfaceChannel.Unsafe
-
flush0
protected void flush0() -
handleWriteError
-
newClosedChannelException
-
voidPromise
Description copied from interface:Channel.Unsafe
Return a special ChannelPromise which can be reused and passed to the operations inChannel.Unsafe
. It will never be notified of a success or error and so is only a placeholder for operations that take aChannelPromise
as argument but for which you not want to get notified.- Specified by:
voidPromise
in interfaceChannel.Unsafe
-
ensureOpen
-
safeSetSuccess
Marks the specifiedpromise
as success. If thepromise
is done already, log a message. -
safeSetFailure
Marks the specifiedpromise
as failure. If thepromise
is done already, log a message. -
closeIfClosed
protected final void closeIfClosed() -
invokeLater
-
annotateConnectException
Appends the remote address to the message of the exceptions caused by connection attempt failure. -
prepareToClose
Prepares to close theChannel
. If this method returns anExecutor
, the caller must call theExecutor.execute(Runnable)
method with a task that callsAbstractChannel.doClose()
on the returnedExecutor
. If this method returnsnull
,AbstractChannel.doClose()
must be called from the caller thread. (i.e.EventLoop
)
-