PayloadEvent
Payload Event mechanism
Use of Event Queue
An event queue needs to be used, as the purpose of this object is to allow multiple events to be scheduled, and to enable them to be distinguished by the use of a payload. Therefore this is an "extension" of the event queue mechanism
To build it means replacing much of the heart of the event queue, so it has been built in the same way as event_queue rather than inheriting from it.
Mechanism
The payload event queue (peq) carries priority queue of pairs, (event and payload). Inside the "peq" there are 2 events. First an event which is used internally to "trigger" the processing of the queue, and then an event that is signalled by the peq to notify methods that are sensitive to it.
This "2" event mechanism is used to guarantee that the queue processing happens before the methods are scheduled. Unlike the case of the normal event queue which does not need to take payloads into account.
The queue processing handles the payloads.
The "top of the queue" is always the last event being processed. When the queue is processed, this event, and it's associated payload is deleted (and not before).
Then the next event is found, and it's payload prepared for delivery.
Then all methods are notified (using the second event). They are notified in this delta cycle.
"peek" or "ready to pop" needed
If a module is sensitive to many events (or ports), then it needs a way of finding which one caused the event.To do this, each payload event queue can be polled to find out if the current event is scheduled for this delta cycle.
There can NOT be several outstanding events in one delta cycle, so at most there should only ever be one payload in an PEQ ready for delivery.
multiple bound ports
multiple modules may be sensitive to the same event.
Posted January 8th, 2008 by MarkBurton