comparison doc/thread-refs.txt @ 8145:b296beccb70e HEAD

Minor cleanup to thread indexing document.
author Timo Sirainen <tss@iki.fi>
date Mon, 01 Sep 2008 15:11:54 +0300
parents 7760a30a5f7e
children
comparison
equal deleted inserted replaced
8144:ea5f84256c3f 8145:b296beccb70e
67 message" link, i.e. "number of links to parent node". However since parents 67 message" link, i.e. "number of links to parent node". However since parents
68 can change, not all of these references might be from our current child 68 can change, not all of these references might be from our current child
69 nodes. When this refcount reaches 0, it means we must detach from our 69 nodes. When this refcount reaches 0, it means we must detach from our
70 parent. 70 parent.
71 expunge_rebuilds: If this message gets expunged, rebuild the thread tree. 71 expunge_rebuilds: If this message gets expunged, rebuild the thread tree.
72 parent_unref_rebuilds: If a link between this node and its child gets 72 child_unref_rebuilds: If a link between this node and its child gets
73 unreferenced, rebuild the thread tree. 73 unreferenced, rebuild the thread tree.
74 } 74 }
75 75
76 link_reference(parent_node, child_node) 76 link_reference(parent_node, child_node)
77 child_node.parent_link_refcount++ 77 child_node.parent_link_refcount++
83 // #1: a -> b (a.ref=1, b.ref=1) 83 // #1: a -> b (a.ref=1, b.ref=1)
84 // #2: b -> a (a.ref=2, b.ref=2) 84 // #2: b -> a (a.ref=2, b.ref=2)
85 // #3: c -> a -> b (a.ref=3, b.ref=3, c.ref=1) 85 // #3: c -> a -> b (a.ref=3, b.ref=3, c.ref=1)
86 // Expunging #3 wouldn't break the loop, but expunging #1 would. 86 // Expunging #3 wouldn't break the loop, but expunging #1 would.
87 for node in nodes[parent_node.parent .. child_node] 87 for node in nodes[parent_node.parent .. child_node]
88 node.parent_unref_rebuilds = true 88 node.child_unref_rebuilds = true
89 else if child_node.parent == parent_node 89 else if child_node.parent == parent_node
90 // The same link already exists 90 // The same link already exists
91 else 91 else
92 // Set parent_node as child_node's parent 92 // Set parent_node as child_node's parent
93 if child_node.parent == NIL 93 if child_node.parent == NIL
107 // several ways: 107 // several ways:
108 // a) Link to original parent node gets unreferenced 108 // a) Link to original parent node gets unreferenced
109 // b) Link to this node gets unreferenced 109 // b) Link to this node gets unreferenced
110 // c) Any of the child nodes gets expunged 110 // c) Any of the child nodes gets expunged
111 // b) is probably the least likely to happen, so use it 111 // b) is probably the least likely to happen, so use it
112 child_node.parent_unref_rebuilds = true 112 child_node.child_unref_rebuilds = true
113 113
114 thread_add_msg(uid) 114 thread_add_msg(uid)
115 // get the Message-IDs as specified by the thread spec 115 // get the Message-IDs as specified by the thread spec
116 (msgid, parent_msgid, references) = message_get_thread_headers(uid) 116 (msgid, parent_msgid, references) = message_get_thread_headers(uid)
117 117
141 // go through References (skipping the last one) 141 // go through References (skipping the last one)
142 for (ref_parent, ref_child) in references 142 for (ref_parent, ref_child) in references
143 link_reference(nodes[ref_parent], nodes[ref_child]) 143 link_reference(nodes[ref_parent], nodes[ref_child])
144 144
145 unref_link(parent, child) 145 unref_link(parent, child)
146 if parent.parent_unref_rebuilds 146 if parent.child_unref_rebuilds
147 return false 147 return false
148 148
149 child.parent_link_refcount-- 149 child.parent_link_refcount--
150 if child.parent_link_refcount == 0 150 if child.parent_link_refcount == 0
151 child.parent = NIL 151 child.parent = NIL