Next: , Previous: , Up: Referable Objects   [Index]


4.2.7.3 How References Are Tracked

Objects belonging to third class data types (data types for which objects may be referred more than once and can store references to other objects) maintain a list of references hold by other objects to themselves, in excess the reference count.

The items in the list are references (pointers, that is) to object descriptions of objects holding the references. For such purpose, data types in this third class of data types include in their definition an object description usable for reference management. Effectively, objects have pointers to objects referring them.

Object descriptions are exchanged as struct x1f4_nodelink_type records.

See struct x1f4_nodelink_type.

The maintained list of references serves cycles detection. The detection is done (by the libaime data type implementations) by tracing up the references until an object is found to be referred by a variable or until there are no more references to trace. In the very first case no object destruction is in order, in the second a set of objects has been determined to have no references to it from outside and needs dismantling.

The tracing up method was selected for performance considerations: objects of the third class are more likely to refer other objects than to be themselves referred (consider collections such as sequences and associative arrays). Equally, references tend to organize themselves in tree structures, and going up is going in the direction in which the structure narrows. Lastly, going up is the optimistic approach (and the one with the better chances to finish quickly) of looking for a referring variable.


Next: Detecting Cycles, Previous: Object Classes, Up: Referable Objects   [Index]