|
Rice Pastry API | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
rice.selector.SelectorManager
This class is the class which handles the selector, and listens for activity. When activity occurs, it figures out who is interested in what has happened, and hands off to that object.
Field Summary | |
protected java.util.HashSet |
cancelledKeys
DESCRIBE THE FIELD |
protected java.util.LinkedList |
invocations
DESCRIBE THE FIELD |
protected java.util.HashSet |
modifyKeys
DESCRIBE THE FIELD |
protected java.nio.channels.Selector |
selector
DESCRIBE THE FIELD |
static int |
TIMEOUT
DESCRIBE THE FIELD |
protected java.util.TreeSet |
timerQueue
DESCRIBE THE FIELD |
protected long |
wakeupTime
DESCRIBE THE FIELD |
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
protected |
SelectorManager(boolean profile)
Constructor, which is private since there is only one selector per JVM. |
Method Summary | |
void |
addLoopObserver(LoopObserver lo)
Adds a feature to the LoopObserver attribute of the SelectorManager object |
void |
cancel(java.nio.channels.SelectionKey key)
Method which asks the Selector Manager to add the given key to the cancelled set. |
protected void |
doInvocations()
Method which invokes all pending invocations. |
protected void |
doSelections()
DESCRIBE THE METHOD |
protected void |
executeDueTasks()
Internal method which finds all due tasks and executes them. |
protected java.lang.Runnable |
getInvocation()
Method which synchroniously returns the first element off of the invocations list. |
java.nio.channels.SelectionKey |
getKey(java.nio.channels.SelectableChannel channel)
Utility method which returns the SelectionKey attached to the given channel, if one exists |
protected java.nio.channels.SelectionKey |
getModifyKey()
Method which synchroniously returns on element off of the modifyKeys list |
int |
getNumInvocations()
Debug method which returns the number of pending invocations |
static SelectorManager |
getSelectorManager()
Returns the SelectorManager applications should use. |
Timer |
getTimer()
Returns the timer associated with this SelectorManager (in this case, it is this). |
void |
invoke(java.lang.Runnable d)
This method schedules a runnable task to be done by the selector thread during the next select() call. |
static boolean |
isSelectorThread()
Returns whether or not this thread of execution is the selector thread |
void |
modifyKey(java.nio.channels.SelectionKey key)
Adds a selectionkey handler into the list of handlers which wish to change their keys. |
protected void |
notifyLoopListeners()
DESCRIBE THE METHOD |
protected void |
onLoop()
This method is to be implemented by a subclass to do some task each loop. |
java.nio.channels.SelectionKey |
register(java.nio.channels.SelectableChannel channel,
SelectionKeyHandler handler,
int ops)
Registers a new channel with the selector, and attaches the given SelectionKeyHandler as the handler for the newly created key. |
void |
removeLoopObserver(LoopObserver lo)
DESCRIBE THE METHOD |
void |
run()
This method starts the socket manager listening for events. |
void |
schedule(TimerTask task,
java.util.Date time)
Method which schedules a task to run at a specified time |
void |
schedule(TimerTask task,
java.util.Date firstTime,
long period)
Method which schedules a task to run repeatedly first at a specified time and period |
void |
schedule(TimerTask task,
long delay)
Method which schedules a task to run after a specified number of millis |
void |
schedule(TimerTask task,
long delay,
long period)
Method which schedules a task to run repeatedly after a specified delay and period |
void |
scheduleAtFixedRate(TimerTask task,
java.util.Date firstTime,
long period)
Method which schedules a task to run repeatedly (at a fixed rate) after a specified delay and period |
void |
scheduleAtFixedRate(TimerTask task,
long delay,
long period)
Method which schedules a task to run repeatedly (at a fixed rate) after a specified delay and period |
protected java.nio.channels.SelectionKey[] |
selectedKeys()
Selects all of the currenlty selected keys on the selector and returns the result as an array of keys. |
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, 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 |
Field Detail |
protected java.nio.channels.Selector selector
protected java.util.LinkedList invocations
protected java.util.HashSet modifyKeys
protected java.util.HashSet cancelledKeys
protected java.util.TreeSet timerQueue
protected long wakeupTime
public static int TIMEOUT
Constructor Detail |
protected SelectorManager(boolean profile)
profile
- DESCRIBE THE PARAMETERMethod Detail |
public java.nio.channels.SelectionKey getKey(java.nio.channels.SelectableChannel channel)
channel
- The channel to return the key for
public int getNumInvocations()
protected java.lang.Runnable getInvocation()
protected java.nio.channels.SelectionKey getModifyKey()
public Timer getTimer()
public void cancel(java.nio.channels.SelectionKey key)
key
- The key to cancelpublic java.nio.channels.SelectionKey register(java.nio.channels.SelectableChannel channel, SelectionKeyHandler handler, int ops) throws java.io.IOException
channel
- The channel to regster with the selectorhandler
- The handler to use for the callbacksops
- The initial interest operations
java.io.IOException
- DESCRIBE THE EXCEPTIONpublic void invoke(java.lang.Runnable d)
d
- The runnable task to invokepublic void modifyKey(java.nio.channels.SelectionKey key)
key
- The key which is to be chanegdprotected void onLoop()
public void run()
run
in interface java.lang.Runnable
protected void notifyLoopListeners()
public void addLoopObserver(LoopObserver lo)
lo
- The feature to be added to the LoopObserver attributepublic void removeLoopObserver(LoopObserver lo)
lo
- DESCRIBE THE PARAMETERprotected void doSelections() throws java.io.IOException
java.io.IOException
- DESCRIBE THE EXCEPTIONprotected void doInvocations()
protected java.nio.channels.SelectionKey[] selectedKeys() throws java.io.IOException
java.io.IOException
- DESCRIBE THE EXCEPTIONpublic void schedule(TimerTask task, long delay)
schedule
in interface Timer
task
- The task to rundelay
- The delaypublic void schedule(TimerTask task, java.util.Date time)
task
- The task to runtime
- The time to runpublic void schedule(TimerTask task, long delay, long period)
schedule
in interface Timer
task
- The task to rundelay
- The delayperiod
- The period with which to runpublic void schedule(TimerTask task, java.util.Date firstTime, long period)
task
- The task to runfirstTime
- The first timeperiod
- The period with which to runpublic void scheduleAtFixedRate(TimerTask task, long delay, long period)
scheduleAtFixedRate
in interface Timer
task
- The task to rundelay
- The delayperiod
- The period with which to runpublic void scheduleAtFixedRate(TimerTask task, java.util.Date firstTime, long period)
task
- The task to runperiod
- The period with which to runfirstTime
- DESCRIBE THE PARAMETERprotected void executeDueTasks()
public static SelectorManager getSelectorManager()
public static boolean isSelectorThread()
|
Rice Pastry API | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |