next up previous contents index
Next: The class choice Up: Datahandlers Previous: The class transport

The class waitqueue

The class waitqueue  can be used to hold data objects until an operation is ready to process the data. It can also hold data that has to wait for another data object before it is ready to be processed by an operation.

interface waitqueue : public event, public queue, public datahandler
{
public:
  waitqueue();                                  // constructor
  waitqueue(histogram* h1, histogram* h2);      // constructor with histograms

  int operator()();                             // application operator
  int accept(data* d);                          // put the data in the waitqueue
  void previous(datahandler* dh);               // set up to 2 previous handlers
};

A waitqueue is created using one of the two contructors. If one wants to gather information about the queue length and waiting times, the second constructor should be used. The first histogram should be of type WEIGTHED, the second of type FREQUENCY.

When the processmodel is being created, at most two other datahandlers will have there successor set to one waitqueue. Because those handlers call waitqueue::previous, the waitqueue knows its precessors. This way the waitqueue knows whether it is an ordinary queue with one precessor, or a waitqueue, with two previous datahandlers. Note that the waitqueue will assume that the first call of previous sets the datahandler that provides the original data objects, and that the second call of previous specifies the handler that provides the copies.

When being created, the waitqueue will put itself on the conditional list to ensure its application operator is called each time something changes in the simulation. When the application operator gets called it will look in the waitqueue to see whether there are some data objects that are ready to be processed. If there are such objects, the waitqueue will try to pass them, one at a time, to the next datahandler until the next handler does not accept any more data objects.

The member accept will allways accept the data objects it gets offered. If the object is not a copy it will simply be added to the queue. If it is a copy of another data object (the source), the copy will directly be terminated. If the source is already in the queue, the source will have its queuingpriority increased. That way it will move to the front of the queue. If the source is not yet in the waitqueue an event will be made conditional to watch for it. If the source arrives at the queue the event will raise the queuingpriority of the source.



next up previous contents index
Next: The class choice Up: Datahandlers Previous: The class transport



A Eliëns
Mon Jun 1 11:51:50 MET DST 1998