| Subject: |
|
Re: How do events get recycled? |
| Name: |
|
Miro Samek |
| Date Posted: |
|
Apr 17, 08 - 6:06 PM |
| Email: |
|
miro@quantum-leaps.com |
| Website: |
|
http://www.quantum-leaps.com |
| Message: |
|
Ama,
QF v3 and v4 work differently than QF v2.x described int the first edition of the PSiCC book. In particular, starting from version 3, QF uses the standard reference counting algorithm to account for all outstanding references to an event. Because the framework actually controls the whole lifecycle of an event (from cradle-to-grave), the framework can do all the incrementing and decrementing of reference counters internally and completely transparently to the application. The framework recycles an event only when the reference counter drops to zero.
So, events aren't always immediately destroyed when they are used. For example, after publishing of an event, more than one AO can reference the event in its event queue. In this case, QF will recycle the event only after the *last* AO completes its RTC step of this event.
To ultimately understand how this works, please see the source code of QActive_postFIFO() and QF_gc(), where you'll see incrementing and decrementing the reference counters. Also, please google for "reference counting" and read about this standard algorithm.
Miro |
|
|
|
|
|
|