Class Reactor

java.lang.Object
java.lang.Thread
com.google.code.yanf4j.nio.impl.Reactor
All Implemented Interfaces:
Runnable

public final class Reactor extends Thread
Reactor pattern
  • Field Details

    • JVMBUG_THRESHHOLD

      public static final int JVMBUG_THRESHHOLD
      JVM bug threshold
    • JVMBUG_THRESHHOLD2

      public static final int JVMBUG_THRESHHOLD2
    • JVMBUG_THRESHHOLD1

      public static final int JVMBUG_THRESHHOLD1
    • DEFAULT_WAIT

      public static final int DEFAULT_WAIT
      See Also:
    • log

      private static final org.slf4j.Logger log
    • jvmBug0

      private boolean jvmBug0
    • jvmBug1

      private boolean jvmBug1
    • reactorIndex

      private final int reactorIndex
    • selectorManager

      private final SelectorManager selectorManager
    • jvmBug

      private final AtomicInteger jvmBug
    • lastJVMBug

      private long lastJVMBug
    • selector

      private Selector selector
    • controller

      private final NioController controller
    • configuration

      private final Configuration configuration
    • wakenUp

      private final AtomicBoolean wakenUp
    • register

      private Queue<Reactor.RegisterEvent> register
    • gate

      private final Lock gate
    • selectTries

      private int selectTries
    • nextTimeout

      private long nextTimeout
    • lastCheckTimestamp

      private long lastCheckTimestamp
  • Constructor Details

  • Method Details

    • getSelector

      public final Selector getSelector()
    • getReactorIndex

      public int getReactorIndex()
    • run

      public void run()
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Thread
    • lookJVMBug

      private boolean lookJVMBug(long before, int selected, long wait) throws IOException
      Look jvm bug
      Parameters:
      before -
      selected -
      wait -
      Returns:
      Throws:
      IOException
    • dispatchEvent

      public final void dispatchEvent(Set<SelectionKey> selectedKeySet)
      Dispatch selected event
      Parameters:
      selectedKeySet -
    • unregisterChannel

      final void unregisterChannel(SelectableChannel channel) throws IOException
      Throws:
      IOException
    • checkSessionTimeout

      private final long checkSessionTimeout()
      Check session timeout or idle
      Returns:
    • isNeedCheckSessionIdleTimeout

      private boolean isNeedCheckSessionIdleTimeout()
    • getSessionFromAttchment

      private final Session getSessionFromAttchment(SelectionKey key)
    • registerSession

      public final void registerSession(Session session, EventType event)
    • isReactorThread

      private final boolean isReactorThread()
    • beforeSelect

      final void beforeSelect()
    • processRegister

      private final void processRegister()
    • getConfiguration

      Configuration getConfiguration()
    • dispatchSessionEvent

      private final void dispatchSessionEvent(Session session, EventType event)
    • postSelect

      public final void postSelect(Set<SelectionKey> selectedKeys, Set<SelectionKey> allKeys)
    • checkExpiredIdle

      private long checkExpiredIdle(SelectionKey key, Session session)
    • checkIdle

      private final void checkIdle(Session session)
    • checkExpired

      private final boolean checkExpired(SelectionKey key, Session session)
    • registerChannel

      public final void registerChannel(SelectableChannel channel, int ops, Object attachment)
    • registerChannelNow

      private void registerChannelNow(SelectableChannel channel, int ops, Object attachment)
    • wakeup

      final void wakeup()
    • selectNow

      final void selectNow() throws IOException
      Throws:
      IOException