summaryrefslogtreecommitdiff
path: root/src/core/dom/Node.cpp
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2014-11-03 18:20:58 +0000
committerandreas <andreas@daaaf23c-2e50-4459-9457-1e69db5a47bf>2014-11-03 18:20:58 +0000
commited50d684bf212da7a7a01ddb4bc82928f238f56d (patch)
treed7e830e4f8fc336242a0fd451df025fc5409a6fe /src/core/dom/Node.cpp
parenta0145fffef9a8f220b8fd852d8f78656386881f3 (diff)
fixed bugs in garbage collector, improved handle classes, added some more unit tests
git-svn-id: file:///var/local/svn/basicwriter@97 daaaf23c-2e50-4459-9457-1e69db5a47bf
Diffstat (limited to 'src/core/dom/Node.cpp')
-rw-r--r--src/core/dom/Node.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/core/dom/Node.cpp b/src/core/dom/Node.cpp
index 8df0787..7c4852a 100644
--- a/src/core/dom/Node.cpp
+++ b/src/core/dom/Node.cpp
@@ -187,7 +187,6 @@ void NodeManager::addRef(Node *tar, Node *src)
// Store the tar <- src reference
assert(dTar);
dTar->incrNodeDegree(RefDir::in, src);
-
if (src) {
// Store the src -> tar reference
assert(dSrc);
@@ -222,15 +221,23 @@ void NodeManager::deleteRef(Node *tar, Node *src, bool all)
// is larger than the threshold value and this function was not
// called from inside the deleteNode function
marked.insert(tar);
- if (marked.size() >= threshold) {
- sweep();
- }
}
}
+
+ // Call the garbage collector if the marked size is larger than the actual
+ // value
+ if (marked.size() >= threshold) {
+ sweep();
+ }
}
void NodeManager::deleteNode(Node *n, NodeDescriptor *descr)
{
+ // Abort if the node already is on the "deleted" list
+ if (deleted.find(n) != deleted.end()) {
+ return;
+ }
+
// Increment the recursion depth counter. The "deleteRef" function called
// below
// may descend further into this function and the actual deletion should be
@@ -277,6 +284,11 @@ void NodeManager::purgeDeleted()
void NodeManager::sweep()
{
+ // Only execute sweep on the highest recursion level
+ if (deletionRecursionDepth > 0) {
+ return;
+ }
+
// Set containing nodes which are reachable from a rooted node
std::unordered_set<Node *> reachable;