Class AbstractNioSelector

    • Field Detail

      • nextId

        private static final java.util.concurrent.atomic.AtomicInteger nextId
      • id

        private final int id
      • logger

        protected static final InternalLogger logger
        Internal Netty logger.
      • executor

        private final java.util.concurrent.Executor executor
        Executor used to execute Runnables such as channel registration task.
      • thread

        protected volatile java.lang.Thread thread
        If this worker has been started thread will be a reference to the thread used when starting. i.e. the current thread when the run method is executed.
      • startupLatch

        final java.util.concurrent.CountDownLatch startupLatch
        Count down to 0 when the I/O thread starts and thread is set to non-null.
      • selector

        protected volatile java.nio.channels.Selector selector
        The NIO Selector.
      • wakenUp

        protected final java.util.concurrent.atomic.AtomicBoolean wakenUp
        Boolean that controls determines if a blocked Selector.select should break out of its selection process. In our case we use a timeone for the select method and the select method will block for that time unless waken up.
      • taskQueue

        private final java.util.Queue<java.lang.Runnable> taskQueue
      • cancelledKeys

        private volatile int cancelledKeys
      • shutdownLatch

        private final java.util.concurrent.CountDownLatch shutdownLatch
      • shutdown

        private volatile boolean shutdown
    • Constructor Detail

      • AbstractNioSelector

        AbstractNioSelector​(java.util.concurrent.Executor executor)
      • AbstractNioSelector

        AbstractNioSelector​(java.util.concurrent.Executor executor,
                            ThreadNameDeterminer determiner)
    • Method Detail

      • registerTask

        protected final void registerTask​(java.lang.Runnable task)
      • isIoThread

        protected final boolean isIoThread()
      • rebuildSelector

        public void rebuildSelector()
        Description copied from interface: NioSelector
        Replaces the current Selector with a new Selector to work around the infamous epoll 100% CPU bug.
        Specified by:
        rebuildSelector in interface NioSelector
      • run

        public void run()
        Specified by:
        run in interface java.lang.Runnable
      • processTaskQueue

        private void processTaskQueue()
      • increaseCancelledKeys

        protected final void increaseCancelledKeys()
      • cleanUpCancelledKeys

        protected final boolean cleanUpCancelledKeys()
                                              throws java.io.IOException
        Throws:
        java.io.IOException
      • process

        protected abstract void process​(java.nio.channels.Selector selector)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • select

        protected int select​(java.nio.channels.Selector selector)
                      throws java.io.IOException
        Throws:
        java.io.IOException
      • close

        protected abstract void close​(java.nio.channels.SelectionKey k)
      • createRegisterTask

        protected abstract java.lang.Runnable createRegisterTask​(Channel channel,
                                                                 ChannelFuture future)