/* * Returns the number of total leaves in the tree */ int check_rep(tree_node * parent) { if(parent == NULL) { return 0; } else if(parent->left == NULL && parent->right == NULL) { return 1; } else { return (check_rep(parent->left)+check_rep(parent->right)); } return 0; }
void io_acceptor_store_t::notify_commit() { thr::spinlock_guard_t guard(lock_); while(min_not_committed_iid_ < begin_ + ring_buffer_.size() && init_and_fetch(min_not_committed_iid_)->committed()) { ++min_not_committed_iid_; } assert(check_rep()); }
void io_acceptor_store_t::set_birth(instance_id_t birth) { thr::spinlock_guard_t guard(lock_); wall_ = begin_ = birth_ = birth; min_not_committed_iid_ = next_to_max_touched_iid_ = birth; // can't participate in them any way last_snapshot_ = birth; assert(check_rep()); }
io_acceptor_store_t::err_t io_acceptor_store_t::lookup( instance_id_t iid, ref_t<acceptor_instance_t>* instance) { thr::spinlock_guard_t guard(lock_); if(iid < birth_) { return err_t::DEAD; } else if(iid < begin_) { return err_t::FORGOTTEN; } else if(iid >= wall_) { return err_t::BEHIND_WALL; } else if(iid >= last_snapshot_ + ring_buffer_.size()) { return err_t::UNREACHABLE; } try_expand_to(iid); *instance = init_and_fetch(iid); assert(check_rep()); return err_t::OK; }
void io_acceptor_store_t::move_last_snapshot_to(instance_id_t last_snapshot) { thr::spinlock_guard_t guard(lock_); last_snapshot_ = max(last_snapshot_, last_snapshot); assert(check_rep()); }
void io_acceptor_store_t::move_wall_to(instance_id_t wall) { thr::spinlock_guard_t guard(lock_); wall_ = max(wall_, wall); assert(check_rep()); }