org.jactr.core.queue
Class TimedEventQueue

java.lang.Object
  extended by org.jactr.core.queue.TimedEventQueue

public class TimedEventQueue
extends java.lang.Object

Tracks TimedEvents within the model. A TimedEvent is any event that must occur by a specific time. All buffer actions are created and placed into this queue so that after the production's execution time has expired, the actions will be executed.

Author:
harrison

Constructor Summary
TimedEventQueue(IModel model)
           
 
Method Summary
 void addTimedEventListener(ITimedEventListener tel, java.util.concurrent.Executor executor)
           
 void dispose()
           
 void enqueue(ITimedEvent te)
          queue up the event.
 boolean fireExpiredEvents(double currentTime)
          check the queue for events that should be fired.
 java.util.Collection<ITimedEvent> getFiringEvents()
          return the events that will fire right now.
 IModel getModel()
           
 double getNextEndTime()
          returns the time of the next expiring event, you should check the size first..
 java.util.Collection<ITimedEvent> getPendingEvents()
          return all the events that are pending.
 boolean isEmpty()
          is the queue empty?
 void removeTimedEventListener(ITimedEventListener tel)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimedEventQueue

public TimedEventQueue(IModel model)
Method Detail

dispose

public void dispose()

getModel

public IModel getModel()

isEmpty

public boolean isEmpty()
is the queue empty?


getNextEndTime

public double getNextEndTime()
returns the time of the next expiring event, you should check the size first..


enqueue

public void enqueue(ITimedEvent te)
queue up the event. If the event has already elapsed, it will be fired.


getPendingEvents

public java.util.Collection<ITimedEvent> getPendingEvents()
return all the events that are pending. this is a costly operation and should only be used when absolutely necessary


getFiringEvents

public java.util.Collection<ITimedEvent> getFiringEvents()
return the events that will fire right now. this has a very limited window of viability. This is used to let events that are currently firing get access to the other events that will be (or have been) fired. Once the firing is complete, this will return an empty list.

Returns:

fireExpiredEvents

public boolean fireExpiredEvents(double currentTime)
check the queue for events that should be fired. If an event hasn't expired, its timePassed method will be called with the current time. Those that have expired will have their timeHasElapsed() methods called, removed, and returned to the caller

Parameters:
currentTime -
Since:

addTimedEventListener

public void addTimedEventListener(ITimedEventListener tel,
                                  java.util.concurrent.Executor executor)

removeTimedEventListener

public void removeTimedEventListener(ITimedEventListener tel)