Sea 0.4.0

gov.lbl.dsd.sea
Class Stage

java.lang.Object
  extended bygov.lbl.dsd.sea.Stage

public class Stage
extends Object

A stage has an input queue into which another stage puts events; A stage has one or more threads, which take events from the input queue and hand them to the stage's event handler which processes the events in a non-blocking asynchronous manner.

Note on exception handling: If a RuntimeExceptionis raised within EventHandler.handle(Object)of this stage's event handler, then this stage's ExceptionHandler is called, which should handle the exception in an appropriate application specific manner. If no ExceptionHandler is defined (because it is null) the exception is simply rethrown.

Version:
$Revision: 1.18 $, $Date: 2004/09/16 16:57:15 $

Constructor Summary
Stage(String stageName, EventHandler handler, ExecutorFactory executorFactory, ExceptionHandler exceptionHandler)
          Creates a new stage with the given name, event handler, executor factory and exceptionHandler.
 
Method Summary
 void enqueue(Object event)
          Enqueues the given event onto this stage.
 void enqueue(Object event, Date date)
          Schedules the given event to be enqueued onto this stage at the given (future) time.
 String getName()
          Returns the name of this stage.
 Stage start()
          Initializes the stage and its event handler; Must be called before enqueuing events (otherwise enqueues are ignored); This method can be called at any time but only has an effect only if the stage is stopped.
 void stop()
          Cleans up this stage and its event handler, as well as related threads; Once a stage has been destroyed it can be initialized again by using start; This method can be called at any time but only has an effect if the stage is started.
 String toString()
          Returns a string representation of the receiver.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Stage

public Stage(String stageName,
             EventHandler handler,
             ExecutorFactory executorFactory,
             ExceptionHandler exceptionHandler)
Creates a new stage with the given name, event handler, executor factory and exceptionHandler.

Method Detail

getName

public String getName()
Returns the name of this stage.


toString

public String toString()
Returns a string representation of the receiver.


start

public Stage start()
Initializes the stage and its event handler; Must be called before enqueuing events (otherwise enqueues are ignored); This method can be called at any time but only has an effect only if the stage is stopped.

Returns:
this (for convenient call chaining only)

stop

public void stop()
Cleans up this stage and its event handler, as well as related threads; Once a stage has been destroyed it can be initialized again by using start; This method can be called at any time but only has an effect if the stage is started.


enqueue

public void enqueue(Object event)
Enqueues the given event onto this stage.


enqueue

public void enqueue(Object event,
                    Date date)
Schedules the given event to be enqueued onto this stage at the given (future) time.


Sea 0.4.0