edu.cuny.cat.task
Class SynchronousDispatcher

java.lang.Object
  extended by edu.cuny.cat.task.SynchronousDispatcher
All Implemented Interfaces:
Dispatcher

public class SynchronousDispatcher
extends java.lang.Object
implements Dispatcher

A synchronous event dispatcher without any internal thread.

Version:
$Revision: 1.3 $
Author:
Jinzhong Niu

Field Summary
protected  boolean running
           
protected  DispatchingTaskQueue tasks
           
 
Constructor Summary
SynchronousDispatcher()
           
 
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 terminate()
          terminates the dispatcher.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tasks

protected final DispatchingTaskQueue tasks

running

protected boolean running
Constructor Detail

SynchronousDispatcher

public SynchronousDispatcher()
Method Detail

addTask

public void addTask(DispatchingTask task)
Description copied from interface: Dispatcher
adds a dispatching task to process.

Specified by:
addTask in interface Dispatcher
Parameters:
task - task to process

process

public void process()
Description copied from interface: Dispatcher
to process the pending tasks.

Specified by:
process in interface Dispatcher

processTask

public void processTask(DispatchingTask task)
Description copied from interface: Dispatcher
to add the task and process all pending tasks. This does exactly what Dispatcher.addTask(DispatchingTask) and Dispatcher.process() do together.

Specified by:
processTask in interface Dispatcher

terminate

public void terminate()
Description copied from interface: Dispatcher
terminates the dispatcher.

Specified by:
terminate in interface Dispatcher

getTasks

public DispatchingTask[] getTasks()
Specified by:
getTasks in interface Dispatcher
Returns:
the array of tasks yet to process.