|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
edu.cuny.cat.task.PriorityAsynchronousDispatcher
public class PriorityAsynchronousDispatcher
An asynchronous dispatcher that runs a thread to process tasks. It allows to use a task comparator and the task IDs to support a stable priority queue of tasks.
PrioritySynchronousDispatcher
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
protected int |
counter
|
protected static org.apache.log4j.Logger |
logger
|
protected java.util.PriorityQueue<DispatchingTask> |
tasks
|
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
PriorityAsynchronousDispatcher(java.util.Comparator<DispatchingTask> comparator)
|
Method Summary | |
---|---|
void |
addTask(DispatchingTask task)
adds a dispatching task to process. |
DispatchingTask[] |
getTasks()
|
void |
process()
to process the pending tasks. |
void |
processTask(DispatchingTask task)
to add the task and process all pending tasks. |
void |
run()
|
void |
terminate()
terminates the dispatcher. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, clone, 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, yield |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static org.apache.log4j.Logger logger
protected final java.util.PriorityQueue<DispatchingTask> tasks
protected int counter
Constructor Detail |
---|
public PriorityAsynchronousDispatcher(java.util.Comparator<DispatchingTask> comparator)
Method Detail |
---|
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public void addTask(DispatchingTask task)
Dispatcher
addTask
in interface Dispatcher
task
- task to processpublic void process()
Dispatcher
process
in interface Dispatcher
public void processTask(DispatchingTask task)
Dispatcher
Dispatcher.addTask(DispatchingTask)
and Dispatcher.process()
do together.
processTask
in interface Dispatcher
public void terminate()
Dispatcher
terminate
in interface Dispatcher
public java.lang.String toString()
toString
in class java.lang.Thread
public DispatchingTask[] getTasks()
getTasks
in interface Dispatcher
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |