Previous Page Parent Page Next Page TOC
Intranet | Events | Implementation | Process Queue

Process Queue

To keep track of the processing steps involved in carrying out event assignments we create a process queue. If an event fires two steps are added to the processing queue for each assignment which are the calculation and the execution of the assignment. For each step we must provide additional information about the time point when they must be executed. The time point is either the current time or the current time plus delay.

The process queue must assure that all steps are properly ordered with respect to their processing time point and the value of the prior flag. Additionally, the calculation must appear prior to the execution for each assignment. Steps which have identical values in all three attributes are processed as one block. Please note that after processing a block of execution steps additional steps may have been added to the queue due to cascading events.

Link between calculation and assignment steps
Some connection between the corresponding calculation and assignment steps is needed. Somehow the calculated values of the calculation step need to be stored and passed to the corresponding assignment step. These values need to be stored per step, since one event can fire several times during its own delay. This means we need dynamic memory for the stored values.

Implementation
Since the processing has to be done in blocks it is natural to implement the process queue as a std::multimap. To achieve the ordering described above we must define our own key.

Process Queue Key

Attributes:
double mTimePoint
bool mPrior
bool mIsCalculation

Methods:
bool operator < (const CProcessQueueKey & rhs)
  {
    if (mTimePoint != rhs.mTimePoint) return mTimePoint < rhs.mTimePoint;
    if (mPrior != rhs.mPrior) return mPrior;
    if (mIsCalculation != rhs.mIsCalculation) return mIsCalculation;
    return false;
  }

TODO: For backwards integration the order needs to be corrected with respect to time.

Comment to TODO: We should rather disable backwards integration if we have events. In general it is not possible to reverse events.