Package com.sshtools.synergy.nio
Class SelectorThread
java.lang.Object
java.lang.Thread
com.sshtools.synergy.nio.SelectorThread
- All Implemented Interfaces:
Runnable
Provides management of a single selector.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionSelectorThread(SelectorThreadPool pool, SelectorThreadImpl impl, boolean isPermanent, int maximumNumOfChannels, int id, int idleServicePeriod, int inactivePeriodsPerIdleEvent, SelectorProvider selectorProvider) Construct a new selector thread. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd an operation to the selector.voidcancelKey(SelectionKey key) voidvoidShutdown the thread.intGet the maximum number of channels that this thread can service.intGet the id of this selector thread.intGet the current thread load.booleanIs this a permanent thread?booleanregister(SelectableChannel sc, int ops, Object attachment, boolean wakeUp) Register a channel with the selector.voidrun()The threads main.voidshutdown()voidwakeup()Wakeup the selector.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, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
Constructor Details
-
SelectorThread
public SelectorThread(SelectorThreadPool pool, SelectorThreadImpl impl, boolean isPermanent, int maximumNumOfChannels, int id, int idleServicePeriod, int inactivePeriodsPerIdleEvent, SelectorProvider selectorProvider) throws IOException Construct a new selector thread.- Parameters:
pool- SelectorThreadPoolimpl- SelectorThreadImplisPermanent- booleanmaximumNumOfChannels- intid- intidleServicePeriod- intinactivePeriodsPerIdleEvent- intselectorProvider- SelectorProvider- Throws:
IOException
-
-
Method Details
-
register
public boolean register(SelectableChannel sc, int ops, Object attachment, boolean wakeUp) throws ClosedChannelException Register a channel with the selector.- Parameters:
sc- SelectableChannelops- intattachment- ObjectwakeUp- boolean- Returns:
- boolean
- Throws:
ClosedChannelException
-
closeAllChannels
public void closeAllChannels() -
addSelectorOperation
Add an operation to the selector.- Parameters:
r- Runnable
-
wakeup
public void wakeup()Wakeup the selector. -
getThreadLoad
public int getThreadLoad()Get the current thread load.- Returns:
- int
-
isPermanent
public boolean isPermanent()Is this a permanent thread?- Returns:
- boolean
-
flagShutdown
public void flagShutdown()Shutdown the thread. -
shutdown
public void shutdown() -
getSelectorId
public int getSelectorId()Get the id of this selector thread.- Returns:
- int
-
getMaximumLoad
public int getMaximumLoad()Get the maximum number of channels that this thread can service.- Returns:
- int
-
run
public void run()The threads main. -
cancelKey
-