CubeTwister 2.0alpha142 2012-02-11

ch.randelshofer.util
Class SimpleSequentialDispatcher

java.lang.Object
  extended by ch.randelshofer.util.SimpleSequentialDispatcher

public class SimpleSequentialDispatcher
extends java.lang.Object

Processes Runnable objects sequentially on a processor thread. The order in which the runnable objects are processed is the same in which they were added to the dispatcher.

This is a simple implementation of a sequential dispatcher. This class is a standalone implementation for use by applications, which only need this kind of dispatcher. It has been cludged together from several classes out of the SoftBricks Library.

Version:
1.0 April 26, 2004 Created.
Author:
Werner Randelshofer

Constructor Summary
SimpleSequentialDispatcher()
          Creates a new instance which processes events at Thread.NORM_PRORITY.
SimpleSequentialDispatcher(int priority)
          Creates a new instance which processes events at the desired thread priority.
 
Method Summary
 void clear()
          Clears the event queue.
protected  void collectEvent(java.lang.Object event)
          Collects an event and puts it into the event queue for later processing.
 void dispatch(java.lang.Runnable r)
          Queues the Runnable object for later execution on the processor thread.
protected  void processEvent(java.lang.Object event)
          This method processes a single event on the event processor thread.
 void start()
          Starts the event processor.
 void stop()
          Stops the event processor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleSequentialDispatcher

public SimpleSequentialDispatcher()
Creates a new instance which processes events at Thread.NORM_PRORITY.


SimpleSequentialDispatcher

public SimpleSequentialDispatcher(int priority)
Creates a new instance which processes events at the desired thread priority.

Parameters:
priority - The Thread priority of the event processor.
Method Detail

dispatch

public void dispatch(java.lang.Runnable r)
Queues the Runnable object for later execution on the processor thread.


processEvent

protected void processEvent(java.lang.Object event)
This method processes a single event on the event processor thread.

Parameters:
event - An event from the queue.

collectEvent

protected void collectEvent(java.lang.Object event)
Collects an event and puts it into the event queue for later processing.

Parameters:
event - The event to be put into the queue.

start

public void start()
Starts the event processor.
Note: The event processor is started by default.


stop

public void stop()
Stops the event processor.


clear

public void clear()
Clears the event queue.


(c) Werner Randelshofer.
All rights reserved.