com.maverick.nio
Class SelectorThread

java.lang.Object
  extended by java.lang.Thread
      extended by com.maverick.nio.SelectorThread
All Implemented Interfaces:
java.lang.Runnable

public class SelectorThread
extends java.lang.Thread

Provides management of a single selector.

Author:
Lee David Painter

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
SelectorThread(SelectorThreadPool pool, SelectorThreadImpl impl, boolean isPermanent, int maximumNumOfChannels, int id, int idleServicePeriod, int inactivePeriodsPerIdleEvent, java.nio.channels.spi.SelectorProvider selectorProvider)
          Construct a new selector thread.
 
Method Summary
 void addSelectorOperation(java.lang.Runnable r)
          Add an operation to the selector.
 int getMaximumLoad()
          Get the maximum number of channels that this thread can service.
 int getSelectorId()
          Get the id of this selector thread.
 int getThreadLoad()
          Get the current thread load.
 boolean isPermanent()
          Is this a permanent thread?
 boolean register(java.nio.channels.SelectableChannel sc, int ops, java.lang.Object attachment, boolean wakeUp)
          Register a channel with the selector.
 void run()
          The threads main.
 void shutdown()
          Shutdown the thread.
 void wakeup()
          Wakeup the selector.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SelectorThread

public SelectorThread(SelectorThreadPool pool,
                      SelectorThreadImpl impl,
                      boolean isPermanent,
                      int maximumNumOfChannels,
                      int id,
                      int idleServicePeriod,
                      int inactivePeriodsPerIdleEvent,
                      java.nio.channels.spi.SelectorProvider selectorProvider)
               throws java.io.IOException
Construct a new selector thread.

Parameters:
pool - SelectorThreadPool
impl - SelectorThreadImpl
isPermanent - boolean
maximumNumOfChannels - int
id - int
idleServicePeriod - int
inactivePeriodsPerIdleEvent - int
selectorProvider - SelectorProvider
Throws:
java.io.IOException
Method Detail

register

public boolean register(java.nio.channels.SelectableChannel sc,
                        int ops,
                        java.lang.Object attachment,
                        boolean wakeUp)
                 throws java.nio.channels.ClosedChannelException
Register a channel with the selector.

Parameters:
sc - SelectableChannel
ops - int
attachment - Object
wakeUp - boolean
Returns:
boolean
Throws:
java.nio.channels.ClosedChannelException

addSelectorOperation

public void addSelectorOperation(java.lang.Runnable r)
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

shutdown

public void shutdown()
Shutdown the thread.


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.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread


Copyright © 2003-2008 SSHTools LTD. All Rights Reserved.