[Zodb-checkins] CVS: Packages/StorageGC - GCableGraph.py:1.2

tim@digicool.com tim@digicool.com
Thu, 19 Apr 2001 15:41:44 -0400 (EDT)


Update of /cvs-repository/Packages/StorageGC
In directory korak:/tmp/cvs-serv25933

Modified Files:
	GCableGraph.py 
Log Message:
In the RCGraph "storage", initialize with a magical root node.  It's
magical because it has a refcount of 1 despite have no predecessors.
Intended to ease writing upcoming tests (making a node reachable from
the root will be an easy way to guarantee the node can never
*legitimately* be considered trash).



--- Updated File GCableGraph.py in package Packages/StorageGC --
--- GCableGraph.py	2001/04/19 17:38:51	1.1
+++ GCableGraph.py	2001/04/19 19:41:44	1.2
@@ -4,11 +4,14 @@
     "A simple reference-counted graph class, for testing cyclic GC."
 
     def __init__(self):
+        # Create a magical root node (w/ refcount 1 despite having no
+        # predecessors).
+
         # Map a node to its refcount.
-        self.rc = {}
+        self.rc = {"root": 1}
 
         # Map a node to a list of its successors.
-        self.succs = {}
+        self.succs = {"root": []}
 
     def addnode(self, node):
         if not self.rc.has_key(node):
@@ -76,7 +79,7 @@
 g.addedge(8, 7)
 g.addedge(8, 6)
 g.addedge(6, 8)
-# g.addedge(10, 2)  # should stop any trash collection
+g.addedge(10, 2)  # should stop any trash collection
 g.dump()
 
 gc = CycleGC(g)