Commit 6f2981d0 authored by John Esmet's avatar John Esmet Committed by Yoni Fogel

refs #5828 destroy the root node when the concurrent tree is destroyed.


git-svn-id: file:///svn/toku/tokudb@51345 c7de825b-a66e-492c-adef-691d508d4ae1
parent 25448a74
......@@ -9,11 +9,11 @@
void concurrent_tree::create(comparator *cmp) {
// start with an empty root node. we do this instead of
// setting m_root to null so there's always a root to lock
m_root.init_root(cmp);
m_root.create_root(cmp);
}
void concurrent_tree::destroy(void) {
invariant(is_empty());
m_root.destroy_root();
}
bool concurrent_tree::is_empty(void) {
......
......@@ -32,11 +32,18 @@ void treenode::init(comparator *cmp) {
m_right_child.set(nullptr);
}
void treenode::init_root(comparator *cmp) {
void treenode::create_root(comparator *cmp) {
init(cmp);
m_is_root = true;
}
void treenode::destroy_root(void) {
invariant(is_root());
invariant(is_empty());
toku_mutex_destroy(&m_mutex);
m_cmp = nullptr;
}
void treenode::set_range_and_txnid(const keyrange &range, TXNID txnid) {
// allocates a new copy of the range for this node
m_range.create_copy(range);
......
......@@ -24,7 +24,7 @@ namespace toku {
// - left and right children may be null
//
// to build a tree on top of this abstraction, the user:
// - provides memory for a root node, initializes it via init_root()
// - provides memory for a root node, initializes it via create_root()
// - performs tree operations on the root node. memory management
// below the root node is handled by the abstraction, not the user.
// this pattern:
......@@ -38,8 +38,11 @@ public:
// - node is locked and children are never locked
// - node may be unlocked if no other thread has visibility
// effect: initialize a treenode, marks it as the root
void init_root(comparator *cmp);
// effect: create the root node
void create_root(comparator *cmp);
// effect: destroys the root node
void destroy_root(void);
// effect: sets the txnid and copies the given range for this node
void set_range_and_txnid(const keyrange &range, TXNID txnid);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment