mirror of
https://github.com/MariaDB/server.git
synced 2025-02-02 03:51:50 +01:00
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
This commit is contained in:
parent
95dc3b3635
commit
2ce44e52ee
3 changed files with 16 additions and 6 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue