Package com.google.code.yanf4j.nio.impl
Class Reactor
java.lang.Object
java.lang.Thread
com.google.code.yanf4j.nio.impl.Reactor
- All Implemented Interfaces:
Runnable
Reactor pattern
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classNested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Configurationprivate final NioControllerstatic final intprivate final Lockprivate final AtomicIntegerstatic final intJVM bug thresholdstatic final intstatic final intprivate booleanprivate booleanprivate longprivate longprivate static final org.slf4j.Loggerprivate longprivate final intprivate Queue<Reactor.RegisterEvent> private Selectorprivate final SelectorManagerprivate intprivate final AtomicBooleanFields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionReactor(SelectorManager selectorManager, Configuration configuration, int index) -
Method Summary
Modifier and TypeMethodDescription(package private) final voidprivate final booleancheckExpired(SelectionKey key, Session session) private longcheckExpiredIdle(SelectionKey key, Session session) private final voidprivate final longCheck session timeout or idlefinal voiddispatchEvent(Set<SelectionKey> selectedKeySet) Dispatch selected eventprivate final voiddispatchSessionEvent(Session session, EventType event) (package private) Configurationintfinal Selectorprivate final Sessionprivate booleanprivate final booleanprivate booleanlookJVMBug(long before, int selected, long wait) Look jvm bugfinal voidpostSelect(Set<SelectionKey> selectedKeys, Set<SelectionKey> allKeys) private final voidfinal voidregisterChannel(SelectableChannel channel, int ops, Object attachment) private voidregisterChannelNow(SelectableChannel channel, int ops, Object attachment) final voidregisterSession(Session session, EventType event) voidrun()(package private) final void(package private) final voidunregisterChannel(SelectableChannel channel) (package private) final voidwakeup()Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, toString, yield
-
Field Details
-
JVMBUG_THRESHHOLD
public static final int JVMBUG_THRESHHOLDJVM 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
-
jvmBug
-
lastJVMBug
private long lastJVMBug -
selector
-
controller
-
configuration
-
wakenUp
-
register
-
gate
-
selectTries
private int selectTries -
nextTimeout
private long nextTimeout -
lastCheckTimestamp
private long lastCheckTimestamp
-
-
Constructor Details
-
Reactor
Reactor(SelectorManager selectorManager, Configuration configuration, int index) throws IOException - Throws:
IOException
-
-
Method Details
-
getSelector
-
getReactorIndex
public int getReactorIndex() -
run
public void run() -
lookJVMBug
Look jvm bug- Parameters:
before-selected-wait-- Returns:
- Throws:
IOException
-
dispatchEvent
Dispatch selected event- Parameters:
selectedKeySet-
-
unregisterChannel
- Throws:
IOException
-
checkSessionTimeout
private final long checkSessionTimeout()Check session timeout or idle- Returns:
-
isNeedCheckSessionIdleTimeout
private boolean isNeedCheckSessionIdleTimeout() -
getSessionFromAttchment
-
registerSession
-
isReactorThread
private final boolean isReactorThread() -
beforeSelect
final void beforeSelect() -
processRegister
private final void processRegister() -
getConfiguration
Configuration getConfiguration() -
dispatchSessionEvent
-
postSelect
-
checkExpiredIdle
-
checkIdle
-
checkExpired
-
registerChannel
-
registerChannelNow
-
wakeup
final void wakeup() -
selectNow
- Throws:
IOException
-