SLIDE 8 15 Telematics 2 / Performance Evaluation (WS 17/18): 07 – Complex Queuing System
Organization of the main program
q Use a priority queue to hold the future event set q Main program is a loop that continues as long as stopping rule is not
true (and there are events to be processed)
q Extract next event from queue holding the FES q Set time to the time of this event, update statistics q Call the handler function for this event (included with the event)
■ Passing parameters as included in the event information to this
procedure
q New events are generated by the handler functions themselves
q Just put new events in the future event set, specifying their time of
q Handler functions might event delete events from the FES, does not
happen here
q Initialization: Just put one or more events in the future event set
q No need to poison some kinds of events as they do not even exist
yet
16 Telematics 2 / Performance Evaluation (WS 17/18): 07 – Complex Queuing System
Implementation issues – Version 4
q Have a look at version 4 of our example program q SIMEvent.hpp contains declaration of
q Prototype for handler functions:
typedef void (*handler_fct) (int); Handler functions only take a single integer as parameter
q Class SIMEvent, containing time of occurrence, a handler function
pointer, and some arbitrary data that is to be passed to the handler function
q SIMPriorityQueue.hpp defines a priority queue
q Similar to SIMQueue q Method push has a parameter priority, according to which the queue is
q Usually, priority and time of the event will be identical – priority is
introduced here to make SIMPriorityQueue more general