org.intranet.sim.event
Class EventQueue

java.lang.Object
  extended byorg.intranet.sim.event.EventQueue

public final class EventQueue
extends java.lang.Object


Nested Class Summary
static interface EventQueue.Listener
           
 
Field Summary
private  long currentTime
           
private  java.util.SortedSet eventSet
           
private  long lastEventProcessTime
           
private  long lastTime
           
private  java.util.List listeners
           
 
Constructor Summary
EventQueue()
           
 
Method Summary
 void addEvent(Event event)
           
 void addListener(EventQueue.Listener listener)
           
 long getCurrentTime()
           
 java.util.List getEventList()
           
 long getLastEventProcessTime()
           
 boolean processEventsUpTo(long time)
          Processes events in the event list up to the requested time.
 void removeEvent(Event event)
           
 void removeListener(EventQueue.Listener listener)
           
private  int updateEventProgress()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentTime

private long currentTime

lastTime

private long lastTime

lastEventProcessTime

private long lastEventProcessTime

eventSet

private java.util.SortedSet eventSet

listeners

private java.util.List listeners
Constructor Detail

EventQueue

public EventQueue()
Method Detail

addEvent

public void addEvent(Event event)

removeEvent

public void removeEvent(Event event)

getEventList

public java.util.List getEventList()

processEventsUpTo

public boolean processEventsUpTo(long time)
Processes events in the event list up to the requested time. The method throws an exception if the requested time is before the last processed time mark. The remainging pending events that require updates are also notified.

Parameters:
time - The requested time to process up to in the list of events.
Returns:
true if events were processed
Throws:
java.lang.RuntimeException - When the requested time is before the last time.

updateEventProgress

private int updateEventProgress()

addListener

public void addListener(EventQueue.Listener listener)

removeListener

public void removeListener(EventQueue.Listener listener)

getCurrentTime

public long getCurrentTime()

getLastEventProcessTime

public long getLastEventProcessTime()