[Aptitude-svn-commit] r4069 - in branches/aptitude-0.3/aptitude: .
src/generic
Daniel Burrows
dburrows at costa.debian.org
Sat Sep 10 00:42:53 UTC 2005
Author: dburrows
Date: Sat Sep 10 00:42:50 2005
New Revision: 4069
Modified:
branches/aptitude-0.3/aptitude/ChangeLog
branches/aptitude-0.3/aptitude/src/generic/immset.h
Log:
Add support for cloning tree structures -- creating nonoverlapping
copies for passing information between threads.
Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog (original)
+++ branches/aptitude-0.3/aptitude/ChangeLog Sat Sep 10 00:42:50 2005
@@ -1,5 +1,12 @@
2005-09-09 Daniel Burrows <dburrows at debian.org>
+ * src/generic/immset.h:
+
+ Add routines to create non-overlapping copies of trees (since
+ the overhead from locking the reference count of trees is too
+ high, this is the only way to safely pass set structures between
+ threads).
+
* doc/en/aptitude.xml, src/cmdline/cmdline_prompt.cc:
By popular demand, add a configuration option to bypass the
Modified: branches/aptitude-0.3/aptitude/src/generic/immset.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/generic/immset.h (original)
+++ branches/aptitude-0.3/aptitude/src/generic/immset.h Sat Sep 10 00:42:50 2005
@@ -357,6 +357,17 @@
getLeft().dump(out, indent, level+1, 0);
getRight().dump(out, indent, level+1, 1);
}
+
+ /** Return a new tree that does not share its structure with any
+ * other tree.
+ */
+ wtree_node clone() const
+ {
+ if(empty())
+ return wtree_node();
+ else
+ return wtree_node(getLeft().clone(), getRight().clone());
+ }
};
/** An entire weighted tree.
@@ -715,6 +726,15 @@
{
root.dump(out);
}
+
+ /** Return a new set that does not share memory with the original
+ * set. It is safe for the old and new sets to be simultaneously
+ * accessed by separate threads.
+ */
+ set clone() const
+ {
+ return set(root.clone(), value_compare);
+ }
};
/** Compare two sets. Will produce strange results unless the two
@@ -938,6 +958,14 @@
{
return contents.intersects(other.contents, f);
}
+
+ /** Return a new identical map that does not share memory with
+ * this map.
+ */
+ map clone() const
+ {
+ return map(contents.clone());
+ }
};
};
More information about the Aptitude-svn-commit
mailing list