Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions cpp/tri_state_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ class TriStatePtr {
&state_));
}

// explicit TriStatePtr(std::unique_ptr<BaseT> ptr) : ptr_(std::move(ptr)) {}
explicit TriStatePtr(std::unique_ptr<BaseT> ptr) : ptr_(std::move(ptr)) {}

class SharedRef {
Expand All @@ -95,24 +94,12 @@ class TriStatePtr {
parent_->ref_count_++;
}
SharedRef& operator=(const SharedRef& other) {
this->parent_ = other.parent_;
this->parent_->ref_count_++;
return *this;
}

SharedRef(SharedRef&& other) : parent_(other.parent_) {
other.parent_ = nullptr;
}
SharedRef& operator=(SharedRef&& other) {
this->parent_ = other.parent_;
other.parent_ = nullptr;
parent_ = other.parent_;
parent_->ref_count_++;
return *this;
}

~SharedRef() {
if (parent_ == nullptr) {
return;
}
int32_t ref_count =
parent_->ref_count_.fetch_sub(1, std::memory_order_acq_rel) - 1;
if (ref_count == 0) {
Expand Down
Loading