xo-ordinaltree: notify gc when root changes in rbtree.erase

This commit is contained in:
Roland Conybeare 2025-12-05 09:59:47 -05:00
commit e5c3d4c714
4 changed files with 28 additions and 11 deletions

View file

@ -140,6 +140,12 @@ namespace xo {
* in-progress collection phase
**/
virtual bool check_move(IObject * /*src*/) const { return false; }
/** check write barrier (if impl has write barrier)
* given an object @p parent that contains object pointer @p lhs.
**/
virtual bool check_write_barrier(IObject * /*parent*/,
IObject ** /*lhs*/,
bool /*may_throw*/) const { return true; };
/** write barrier for collector. perform assignment
* @code
* *lhs = rhs

View file

@ -534,15 +534,26 @@ namespace xo {
log("pre", xtag("key", key), xtag("tree", *this));
}
RbNode * adj_root = this->root_;
bool retval = RbUtil::erase_aux(this->node_alloc_,
key,
this->reduce_fn_,
debug_flag_,
&(this->root_));
&adj_root);
if (retval)
if (retval) {
--(this->size_);
if (adj_root != root_) {
allocator_type alloc = node_alloc_;
this->_gc_assign_member(&(this->root_), adj_root, alloc);
}
} else {
assert(adj_root == root_);
}
if (log) {
log("post", xtag("tree", *this));
}

View file

@ -266,8 +266,8 @@ namespace xo {
/* true if this node is red, and either child is red */
bool is_red_violation() const {
if (this->color_ == C_Red) {
Node *left = this->left_child();
Node *right = this->right_child();
Node * left = this->left_child();
Node * right = this->right_child();
if (left && left->is_red())
return true;
@ -455,7 +455,7 @@ namespace xo {
*/
std::pair<ReducedValue, ReducedValue> reduced_;
/* pointer to parent node, nullptr iff this is the root node */
Node *parent_ = nullptr;
Node * parent_ = nullptr;
/*
* .child_v[0] = left child
* .child_v[1] = right child

View file

@ -317,7 +317,7 @@ namespace xo {
*/
static RbNode * find_rightmost(RbNode *N) {
while(N) {
RbNode *S = N->right_child();
RbNode * S = N->right_child();
if (!S)
break;
@ -417,7 +417,7 @@ namespace xo {
return x;
}
RbNode *y = find_lub(x->left_child(), k, is_closed);
RbNode * y = find_lub(x->left_child(), k, is_closed);
if (y) {
/* found better upper bound in left subtree */
@ -911,7 +911,7 @@ namespace xo {
assert(pp_root);
RbNode *P = N->parent();
RbNode * P = N->parent();
if (!P) {
/* N was the root node, tree now empty */
@ -948,9 +948,9 @@ namespace xo {
* C D
*/
Direction other_d;
RbNode *S = nullptr;
RbNode *C = nullptr;
RbNode *D = nullptr;
RbNode * S = nullptr;
RbNode * C = nullptr;
RbNode * D = nullptr;
/* table of outcomes as a function of node color
*