The InputQueue class is a SortedList instantiated with BasicEvent *'s as the type of object to be handled. (Documentation for the SortedList class can be found in Appendix A.) The comparison function given to the InputQueue is a comparison for BasicEvents, allowing the sorting to occur based on recvTimes.
In addition, the insert function has been overridden so that identical events with opposite signs annihilate each other automatically, as should occur according to the TimeWarp methodology. After inserting an event, the insert function returns a boolean that indicates whether or not the event's receive time was before that of the last executed event's, so that the simulation object can do rollback processing if needed. A return value of true indicated that the message was in the past, while a return value of false indicates that it was not.
Another function that is available to the InputQueue is gcollect(VTime). gcollect invalidates any elements in a queue before the VTime passed in. Note that in the InputQueue, Containers will be removed from the list as part of garbage collection, but the data in them won't be deleted . Elements in the InputQ of one TimeWarp object will also be in the outputQ of another. In the WARPED system, it is assumed that the object responsible for newing memory is also responsible for deleteing it, so the sender (who will have a record of the event in it's output queue) will delete it. The gcollect function was intended to be called from TimeWarp::gcollect(VTime) as part of the overall garbage collection that occurs when gVT advances.
Several utility functions have been added to the SortedList class by the InputQueue class. For instance, the find method in the InputQueue class has been overloaded so that it accepts a VTime as the search parameter rather than a pointer to a record. In addition, a method called getAndSeek(), which returns a BasicEvent, has been defined in the InputQueue class. This method returns the next event scheduled for processing, and advances the queue's internal pointer to the next event that should be scheduled.
The interface for the InputQueue class follows:
class InputQueue: public SortedList<BasicEvent> {
public:
InputQueue();
~InputQueue(){};
bool insert(BasicEvent *toInsert); // returns a bool indicating if
// the message inserted was in the
// past or not
BasicEvent *getAndSeek(); // returns the next event to process, and
// advances the internal pointer to the
// NEXT event to process.
BasicEvent *get() const; // get the current event without advancing
// the internal pointer.
BasicEvent *find(VTime, findMode_t = EQUAL); // nicer interface to find.
int gcollect(VTime); // perform garbage collection up until Time.
VTime calculateMin(); // return the time of the lowest unprocessed event.
VTime lastExecuted; // the time of the last event executed. This gets
// updated externally by TimeWarp
};