本文整理汇总了C++中DataNode::dec_ref方法的典型用法代码示例。如果您正苦于以下问题:C++ DataNode::dec_ref方法的具体用法?C++ DataNode::dec_ref怎么用?C++ DataNode::dec_ref使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataNode
的用法示例。
在下文中一共展示了DataNode::dec_ref方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: find
bool InnerNode::find(Slice key, Slice& value, InnerNode *parent)
{
bool ret = false;
read_lock();
if (parent) {
parent->unlock(); // lock coupling
}
int idx = find_pivot(key);
MsgBuf* b = msgbuf(idx);
assert(b);
b->read_lock();
MsgBuf::Iterator it = b->find(key);
if (it != b->end() && it->key == key ) {
if (it->type == Put) {
value = it->value.clone();
ret = true;
}
// otherwise deleted
b->unlock();
unlock();
return ret;
}
b->unlock();
bid_t chidx = child(idx);
if (chidx == NID_NIL) {
assert(idx == 0); // must be the first child
unlock();
return false;
}
// find in child
DataNode* ch = tree_->load_node(chidx, true);
assert(ch);
ret = ch->find(key, value, this);
ch->dec_ref();
return ret;
}
示例2: maybe_cascade
void InnerNode::maybe_cascade()
{
int idx = -1;
if (msgcnt_ >= tree_->options_.inner_node_msg_count) {
idx = find_msgbuf_maxcnt();
} else if (size() >= tree_->options_.inner_node_page_size) {
idx = find_msgbuf_maxsz();
} else {
unlock();
return;
}
assert(idx >= 0);
MsgBuf* b = msgbuf(idx);
bid_t nid = child(idx);
DataNode *node = NULL;
if (nid == NID_NIL) {
// cannot be inner node
assert(bottom_);
node = tree_->new_leaf_node();
set_child(idx, node->nid());
} else {
node = tree_->load_node(nid, false);
}
assert(node);
node->cascade(b, this);
node->dec_ref();
// it's possible to cascade twice
// lock is released in child, so it's nescessarty to obtain it again
read_lock();
if (msgcnt_ >= tree_->options_.inner_node_msg_count ||
size() >= tree_->options_.inner_node_page_size) {
maybe_cascade();
} else {
unlock();
}
}