|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.Thread x10.UnitEventDispatcher
UnitEventDispatcher is a threaded dispatcher that calls each
registered UnitListener when an event comes in. This object
is single-threaded, so all UnitListeners are notified by the
same thread. This is important to note so that UnitListeners
do not "hog" the thread. UnitListeners should quickly return
from handling events as to not delay subsequent listeners
from receiving the event.
This class can be reused by other Controller implementations.
Field Summary |
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
UnitEventDispatcher()
UnitEventDispatcher constructs an unstarted dispatcher. |
Method Summary | |
void |
addUnitListener(UnitListener listener)
addUnitListener adds the specified UnitListener to the list of listeners that are notified by the dispatcher. |
void |
dispatchUnitEvent(UnitEvent event)
dispatchUnitEvent adds the specified UnitEvent to the queue of events to be dispatched. |
void |
kill()
kill terminates the dispatcher thread. |
void |
removeUnitListener(UnitListener listener)
removeUnitListener removes the specified listener. |
void |
run()
run blocks until an event comes in, and then dispatches it to all registered listeners. |
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 |
Constructor Detail |
public UnitEventDispatcher()
Method Detail |
public void run()
public void dispatchUnitEvent(UnitEvent event)
event
- the UnitEvent to be dispatchedpublic void addUnitListener(UnitListener listener)
listener
- the listener to add.public void removeUnitListener(UnitListener listener)
listener
- the listener to be removed.public void kill()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |