Simultaneous Events

An input port may have a sequence of simultaneous events pending (events with identical timestamps). Normally, the primitive will be fired repeatedly until all these events have been consumed. Optionally, a DE primitive may process simultaneous events during a single firing. The getSimulEvent method can be used as in the following example, taken from an up-down counter primitive:

go
{
  ...
  while (countUp.dataNew)
  {
    content++;
    countUp.getSimulEvent();
  }
  ...
}

Here, countUp is an input porthole. The getSimulEvent method examines the global event queue to see if any more events are available for the porthole with the current timestamp. If so, it fetches the next one and sets the dataNew flag to TRUE. If none remain, it sets the dataNew flag to FALSE. In this example, the actual values of the input events are uninteresting, but the primitive could use get() within the loop if it did need the event values.

Sometimes, a primitive simply needs to know how many simultaneous events are pending on a given porthole. Without fetching any event, we can get the number of simultaneous events by calling the numSimulEvents method. This returns the number of simultaneous events still waiting in the global event queue. The one already in the porthole isn’t counted. If the primitive has multiple input ports, the programmer should carefully consider the desired behavior of simultaneous inputs on different ports, and choose the order of processing of events accordingly. For example, it might be appropriate to absorb all the events available for a control porthole before examining any events for a data porthole.