NodeCachedReferenceCount¶
from acron.core import NodeCachedReferenceCount
- class NodeCachedReferenceCount¶
Bases:
Bases:
CachedTypedWritableReferenceCountThis class further specializes
CachedTypedWritableReferenceCountto also add a node_ref_count, for the purposes of counting the number of times the object is referenced by a “node”, presumably aAcronNode.This essentially combines the functionality of
NodeReferenceCountandCachedTypedWritableReferenceCount, so that a derivative of this object actually has three counters: the standard reference count, the “cache” reference count, and the “node” reference count. Rather than multiply inheriting from the two reference count classes, we inherit only fromCachedTypedWritableReferenceCountand simply duplicate the functionality ofNodeReferenceCount, to avoid all of the problems associated with multiple inheritance.The intended design is to use this as a base class for
RenderStateandTransformState, both of which are held byAcronNodes, and also have caches which are independently maintained. By keeping track of how many nodes hold a pointer to a particular object, we can classify each object into node-referenced, cache-referenced, or other, which is primarily useful for PStats reporting.As with CachedTypedWritableReferenceCount’s
cache_ref()andcache_unref(), the new methodsnode_ref()andnode_unref()automatically increment and decrement the primary reference count as well. In this case, however, there does exist a NodePointerTo<> class to maintain thenode_ref()counters automatically.Inheritance diagram
digraph inheritancead2f8c1da2 { bgcolor=transparent; rankdir=BT; size="8.0, 12.0"; "CachedTypedWritableReferenceCount" [URL="acron.core.CachedTypedWritableReferenceCount.html#acron.core.CachedTypedWritableReferenceCount",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="/**"]; "TypedWritableReferenceCount" -> "CachedTypedWritableReferenceCount" [arrowsize=0.75,style=""]; "DTOOL_SUPER_BASE" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style=""]; "NodeCachedReferenceCount" [URL="acron.core.NodeCachedReferenceCount.html#acron.core.NodeCachedReferenceCount",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="/**"]; "CachedTypedWritableReferenceCount" -> "NodeCachedReferenceCount" [arrowsize=0.75,style=""]; "ReferenceCount" [URL="acron.core.ReferenceCount.html#acron.core.ReferenceCount",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="/**"]; "DTOOL_SUPER_BASE" -> "ReferenceCount" [arrowsize=0.75,style=""]; "TypedObject" [URL="acron.core.TypedObject.html#acron.core.TypedObject",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="/**"]; "DTOOL_SUPER_BASE" -> "TypedObject" [arrowsize=0.75,style=""]; "TypedWritable" [URL="acron.core.TypedWritable.html#acron.core.TypedWritable",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="/**"]; "TypedObject" -> "TypedWritable" [arrowsize=0.75,style=""]; "TypedWritableReferenceCount" [URL="acron.core.TypedWritableReferenceCount.html#acron.core.TypedWritableReferenceCount",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="/**"]; "TypedWritable" -> "TypedWritableReferenceCount" [arrowsize=0.75,style=""]; "ReferenceCount" -> "TypedWritableReferenceCount" [arrowsize=0.75,style=""]; }- static get_class_type()¶
- get_node_ref_count()¶
Returns the current reference count.
- get_referenced_bits()¶
Returns the union of the values defined in the Referenced enum that represents the various things that appear to be holding a pointer to this object.
If R_node is included, at least one node is holding a pointer; if R_cache is included, at least one cache element is.
- node_ref()¶
Explicitly increments the reference count.
This function is const, even though it changes the object, because generally fiddling with an object’s reference count isn’t considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.
- node_unref()¶
Explicitly decrements the node reference count and the normal reference count simultaneously.
The return value is true if the new reference count is nonzero, false if it is zero.
- test_ref_count_integrity()¶
Does some easy checks to make sure that the reference count isn’t completely bogus.