Class EpollIoHandler

java.lang.Object
io.netty.channel.epoll.EpollIoHandler
All Implemented Interfaces:
IoHandler

public class EpollIoHandler extends java.lang.Object implements IoHandler
IoHandler which uses epoll under the covers. Only works on Linux!
  • Field Details

  • Constructor Details

  • Method Details

    • newFactory

      public static IoHandlerFactory newFactory()
      Returns a new IoHandlerFactory that creates EpollIoHandler instances.
    • newFactory

      public static IoHandlerFactory newFactory(int maxEvents, SelectStrategyFactory selectStrategyFactory)
      Returns a new IoHandlerFactory that creates EpollIoHandler instances.
    • cast

      private static EpollIoHandle cast(IoHandle handle)
    • cast

      private static EpollIoOps cast(IoOps ops)
    • openFileDescriptors

      @UnstableApi public void openFileDescriptors()
      This method is intended for use by a process checkpoint/restore integration, such as OpenJDK CRaC.
    • closeFileDescriptor

      private static void closeFileDescriptor(FileDescriptor fd)
    • wakeup

      public void wakeup()
      Description copied from interface: IoHandler
      Wakeup the IoHandler, which means if any operation blocks it should be unblocked and return as soon as possible.
      Specified by:
      wakeup in interface IoHandler
    • prepareToDestroy

      public void prepareToDestroy()
      Description copied from interface: IoHandler
      Prepare to destroy this IoHandler. This method will be called before IoHandler.destroy() and may be called multiple times.
      Specified by:
      prepareToDestroy in interface IoHandler
    • destroy

      public void destroy()
      Description copied from interface: IoHandler
      Destroy the IoHandler and free all its resources. Once destroyed using the IoHandler will cause undefined behaviour.
      Specified by:
      destroy in interface IoHandler
    • register

      public IoRegistration register(IoHandle handle) throws java.lang.Exception
      Description copied from interface: IoHandler
      Register a IoHandle for IO.
      Specified by:
      register in interface IoHandler
      Parameters:
      handle - the IoHandle to register.
      Throws:
      java.lang.Exception - thrown if an error happens during registration.
    • isCompatible

      public boolean isCompatible(java.lang.Class<? extends IoHandle> handleType)
      Description copied from interface: IoHandler
      Returns true if the given type is compatible with this IoHandler and so can be registered, false otherwise.
      Specified by:
      isCompatible in interface IoHandler
      Parameters:
      handleType - the type of the IoHandle.
      Returns:
      if compatible of not.
    • numRegisteredChannels

      int numRegisteredChannels()
    • registeredChannelsList

      java.util.List<Channel> registeredChannelsList()
    • epollWait

      private long epollWait(IoHandlerContext context, long deadlineNanos) throws java.io.IOException
      Throws:
      java.io.IOException
    • epollWaitNoTimerChange

      private int epollWaitNoTimerChange() throws java.io.IOException
      Throws:
      java.io.IOException
    • epollWaitNow

      private int epollWaitNow() throws java.io.IOException
      Throws:
      java.io.IOException
    • epollBusyWait

      private int epollBusyWait() throws java.io.IOException
      Throws:
      java.io.IOException
    • epollWaitTimeboxed

      private int epollWaitTimeboxed() throws java.io.IOException
      Throws:
      java.io.IOException
    • run

      public int run(IoHandlerContext context)
      Description copied from interface: IoHandler
      Run the IO handled by this IoHandler. The IoHandlerContext should be used to ensure we not execute too long and so block the processing of other task that are scheduled on the ThreadAwareExecutor. This is done by taking IoHandlerContext.delayNanos(long) or IoHandlerContext.deadlineNanos() into account.
      Specified by:
      run in interface IoHandler
      Parameters:
      context - the IoHandlerContext.
      Returns:
      the number of IoHandle for which I/O was handled. Internal events such as wakeups and timer expirations must not be included in this count.
    • handleLoopException

      void handleLoopException(java.lang.Throwable t)
      Visible only for testing!
    • processReady

      private int processReady(EpollEventArray events, int ready)
    • closeFileDescriptors

      @UnstableApi public void closeFileDescriptors()
      This method is intended for use by process checkpoint/restore integration, such as OpenJDK CRaC. It's up to the caller to ensure that there is no concurrent use of the FDs while these are closed, e.g. by blocking the executor.