org.bluesock.bluemud.driver
Class Engine

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--org.bluesock.bluemud.driver.Engine
All Implemented Interfaces:
java.lang.Runnable

public class Engine
extends java.lang.Thread

The Engine class is responsible for processing mud events. Events can be added to the engine's queue of pending events, which will ultimately be processed in a first-come, first-served order (FIFO). The engine runs until asked to shutdown.


Fields inherited from class java.lang.Thread
inheritableThreadLocals, MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY, threadLocals
 
Constructor Summary
protected Engine()
          Constructor
 
Method Summary
 void addEvent(MudEvent newEvent)
          Request that an event be added to the pending list of events that are to be processed by the engine.
(package private)  long getAverageEventExecutionTime()
          Retrieve the average time it takes to execute an event.
(package private)  long getAverageQueueSize()
          Retrieve the average size of the event queue.
(package private)  int getCurrentQueueSize()
          Retrieve the current size of the event queue.
(package private)  long getTotalNumberEventsProcessed()
          Retrieve the total number of events processed by this Engine instance.
(package private)  long getTotalNumberEventsTerminated()
          Retrieve the total number of events terminated by this Engine instance due to the event taking longer than the established timeout to execute.
 void run()
          Processes pending events.
 void shutdown()
          Request that the engine shutdown.
 
Methods inherited from class java.lang.Thread
, activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, 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

Engine

protected Engine()
Constructor
Method Detail

addEvent

public void addEvent(MudEvent newEvent)
Request that an event be added to the pending list of events that are to be processed by the engine. Events are processed in a first-come, first-served order. Note that this method will ignore a request if this engine is currently pending shutdown.

getCurrentQueueSize

int getCurrentQueueSize()
Retrieve the current size of the event queue. This method exists for statistical and diagnostic purposes.

getAverageQueueSize

long getAverageQueueSize()
Retrieve the average size of the event queue. The average is updated prior to processing of each event (after the event has been removed from the queue). This method exists for statistical and diagnostic purposes.

getAverageEventExecutionTime

long getAverageEventExecutionTime()
Retrieve the average time it takes to execute an event. The average is updated following processing of each event. This method exists for statistical and diagnostic purposes.

getTotalNumberEventsProcessed

long getTotalNumberEventsProcessed()
Retrieve the total number of events processed by this Engine instance. This method exists for statistical and diagnostic purposes.

getTotalNumberEventsTerminated

long getTotalNumberEventsTerminated()
Retrieve the total number of events terminated by this Engine instance due to the event taking longer than the established timeout to execute. This method exists for statistical and diagnostic purposes.

shutdown

public void shutdown()
Request that the engine shutdown. Note that this engine thread won't terminate until (1) this method is invoked and (2) this engine has processed all pending events.

run

public void run()
Processes pending events. If an event takes too long to execute, it will be assumed that it's a runaway event and it will halted. This method returns when the engine has been asked to shutdown and there are no more pending events.
Overrides:
run in class java.lang.Thread


docs generated on Thu Jan 24 08:57:26 CST 2002