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 class
static class
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Configuration
private final NioController
static final int
private final Lock
private final AtomicInteger
static final int
JVM bug thresholdstatic final int
static final int
private boolean
private boolean
private long
private long
private static final org.slf4j.Logger
private long
private final int
private Queue
<Reactor.RegisterEvent> private Selector
private final SelectorManager
private int
private final AtomicBoolean
Fields 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 void
private final boolean
checkExpired
(SelectionKey key, Session session) private long
checkExpiredIdle
(SelectionKey key, Session session) private final void
private final long
Check session timeout or idlefinal void
dispatchEvent
(Set<SelectionKey> selectedKeySet) Dispatch selected eventprivate final void
dispatchSessionEvent
(Session session, EventType event) (package private) Configuration
int
final Selector
private final Session
private boolean
private final boolean
private boolean
lookJVMBug
(long before, int selected, long wait) Look jvm bugfinal void
postSelect
(Set<SelectionKey> selectedKeys, Set<SelectionKey> allKeys) private final void
final void
registerChannel
(SelectableChannel channel, int ops, Object attachment) private void
registerChannelNow
(SelectableChannel channel, int ops, Object attachment) final void
registerSession
(Session session, EventType event) void
run()
(package private) final void
(package private) final void
unregisterChannel
(SelectableChannel channel) (package private) final void
wakeup()
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
-