Class AbstractChannel.AbstractUnsafe

java.lang.Object
io.netty.channel.AbstractChannel.AbstractUnsafe
All Implemented Interfaces:
Channel.Unsafe
Direct Known Subclasses:
AbstractEpollChannel.AbstractEpollUnsafe, AbstractIoUringChannel.AbstractUringUnsafe, AbstractKQueueChannel.AbstractKQueueUnsafe, AbstractNioChannel.AbstractNioUnsafe, AbstractOioChannel.DefaultOioUnsafe, AbstractServerChannel.DefaultServerUnsafe, EmbeddedChannel.EmbeddedUnsafe, FailedChannel.FailedChannelUnsafe, LocalChannel.LocalUnsafe, LocalServerChannel.LocalServerUnsafe
Enclosing class:
AbstractChannel

protected abstract class AbstractChannel.AbstractUnsafe extends java.lang.Object implements Channel.Unsafe
Channel.Unsafe implementation which sub-classes must extend and use.
  • Field Details

    • outboundBuffer

      private volatile ChannelOutboundBuffer outboundBuffer
    • recvHandle

      private RecvByteBufAllocator.Handle recvHandle
    • inFlush0

      private boolean inFlush0
    • neverRegistered

      private boolean neverRegistered
      true if the channel has never been registered, false otherwise
  • Constructor Details

    • AbstractUnsafe

      protected AbstractUnsafe()
  • Method Details

    • assertEventLoop

      private void assertEventLoop()
    • recvBufAllocHandle

      public RecvByteBufAllocator.Handle recvBufAllocHandle()
      Description copied from interface: Channel.Unsafe
      Return the assigned RecvByteBufAllocator.Handle which will be used to allocate ByteBuf's when receiving data.
      Specified by:
      recvBufAllocHandle in interface Channel.Unsafe
    • outboundBuffer

      public final ChannelOutboundBuffer outboundBuffer()
      Description copied from interface: Channel.Unsafe
      Returns the ChannelOutboundBuffer of the Channel where the pending write requests are stored.
      Specified by:
      outboundBuffer in interface Channel.Unsafe
    • localAddress

      public final java.net.SocketAddress localAddress()
      Description copied from interface: Channel.Unsafe
      Return the SocketAddress to which is bound local or null if none.
      Specified by:
      localAddress in interface Channel.Unsafe
    • remoteAddress

      public final java.net.SocketAddress remoteAddress()
      Description copied from interface: Channel.Unsafe
      Return the SocketAddress to which is bound remote or null if none is bound yet.
      Specified by:
      remoteAddress in interface Channel.Unsafe
    • register

      public final void register(EventLoop eventLoop, ChannelPromise promise)
      Description copied from interface: Channel.Unsafe
      Register the Channel of the ChannelPromise and notify the ChannelFuture once the registration was complete.
      Specified by:
      register in interface Channel.Unsafe
    • register0

      private void register0(ChannelPromise promise)
    • bind

      public final void bind(java.net.SocketAddress localAddress, ChannelPromise promise)
      Description copied from interface: Channel.Unsafe
      Bind the SocketAddress to the Channel of the ChannelPromise and notify it once its done.
      Specified by:
      bind in interface Channel.Unsafe
    • disconnect

      public final void disconnect(ChannelPromise promise)
      Description copied from interface: Channel.Unsafe
      Disconnect the Channel of the ChannelFuture and notify the ChannelPromise once the operation was complete.
      Specified by:
      disconnect in interface Channel.Unsafe
    • close

      public void close(ChannelPromise promise)
      Description copied from interface: Channel.Unsafe
      Close the Channel of the ChannelPromise and notify the ChannelPromise once the operation was complete.
      Specified by:
      close in interface Channel.Unsafe
    • shutdownOutput

      public final void shutdownOutput(ChannelPromise promise)
      Shutdown the output portion of the corresponding Channel. For example this will clean up the ChannelOutboundBuffer and not allow any more writes.
    • shutdownOutput

      private void shutdownOutput(ChannelPromise promise, java.lang.Throwable cause)
      Shutdown the output portion of the corresponding Channel. For example this will clean up the ChannelOutboundBuffer 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, java.lang.Throwable cause)
    • close

      protected void close(ChannelPromise promise, java.lang.Throwable cause, java.nio.channels.ClosedChannelException closeCause)
    • doClose0

      private void doClose0(ChannelPromise promise)
    • fireChannelInactiveAndDeregister

      private void fireChannelInactiveAndDeregister(boolean wasActive)
    • closeForcibly

      public final void closeForcibly()
      Description copied from interface: Channel.Unsafe
      Closes the Channel immediately without firing any events. Probably only useful when registration attempt failed.
      Specified by:
      closeForcibly in interface Channel.Unsafe
    • deregister

      public void deregister(ChannelPromise promise)
      Description copied from interface: Channel.Unsafe
      Deregister the Channel of the ChannelPromise from EventLoop and notify the ChannelPromise once the operation was complete.
      Specified by:
      deregister in interface Channel.Unsafe
    • deregister

      private void deregister(ChannelPromise promise, boolean fireChannelInactive)
    • beginRead

      public final void beginRead()
      Description copied from interface: Channel.Unsafe
      Schedules a read operation that fills the inbound buffer of the first ChannelInboundHandler in the ChannelPipeline. If there's already a pending read operation, this method does nothing.
      Specified by:
      beginRead in interface Channel.Unsafe
    • write

      public final void write(java.lang.Object msg, ChannelPromise promise)
      Description copied from interface: Channel.Unsafe
      Schedules a write operation.
      Specified by:
      write in interface Channel.Unsafe
    • flush

      public final void flush()
      Description copied from interface: Channel.Unsafe
      Flush out all write operations scheduled via Channel.Unsafe.write(Object, ChannelPromise).
      Specified by:
      flush in interface Channel.Unsafe
    • flush0

      protected void flush0()
    • handleWriteError

      protected final void handleWriteError(java.lang.Throwable t)
    • newClosedChannelException

      private java.nio.channels.ClosedChannelException newClosedChannelException(java.lang.Throwable cause, java.lang.String method)
    • voidPromise

      public final ChannelPromise voidPromise()
      Description copied from interface: Channel.Unsafe
      Return a special ChannelPromise which can be reused and passed to the operations in Channel.Unsafe. It will never be notified of a success or error and so is only a placeholder for operations that take a ChannelPromise as argument but for which you not want to get notified.
      Specified by:
      voidPromise in interface Channel.Unsafe
    • ensureOpen

      protected final boolean ensureOpen(ChannelPromise promise)
    • safeSetSuccess

      protected final void safeSetSuccess(ChannelPromise promise)
      Marks the specified promise as success. If the promise is done already, log a message.
    • safeSetFailure

      protected final void safeSetFailure(ChannelPromise promise, java.lang.Throwable cause)
      Marks the specified promise as failure. If the promise is done already, log a message.
    • closeIfClosed

      protected final void closeIfClosed()
    • invokeLater

      private void invokeLater(java.lang.Runnable task)
    • annotateConnectException

      protected final java.lang.Throwable annotateConnectException(java.lang.Throwable cause, java.net.SocketAddress remoteAddress)
      Appends the remote address to the message of the exceptions caused by connection attempt failure.
    • prepareToClose

      protected java.util.concurrent.Executor prepareToClose()
      Prepares to close the Channel. If this method returns an Executor, the caller must call the Executor.execute(Runnable) method with a task that calls AbstractChannel.doClose() on the returned Executor. If this method returns null, AbstractChannel.doClose() must be called from the caller thread. (i.e. EventLoop)