From 95d184ba209fd3dc9d38b351fd580dfcaa9b961c Mon Sep 17 00:00:00 2001 From: chenchong_666 Date: Mon, 19 Jun 2023 09:53:39 +0800 Subject: [PATCH] test Signed-off-by: chenchong_666 --- base/include/refbase.h | 6 ++++++ base/src/refbase.cpp | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/base/include/refbase.h b/base/include/refbase.h index 8122d81..01fef21 100644 --- a/base/include/refbase.h +++ b/base/include/refbase.h @@ -212,6 +212,12 @@ public: virtual void OnLastWeakRef(const void *objectId); virtual bool OnAttemptPromoted(const void *objectId); + /** + * @brief Get the pointer to corresponding counter object. + * + * @return Pointer to the counter object. + */ + RefCounter *GetRefCounter() const; private: RefCounter *refs_ = nullptr; diff --git a/base/src/refbase.cpp b/base/src/refbase.cpp index fb46127..54f2557 100644 --- a/base/src/refbase.cpp +++ b/base/src/refbase.cpp @@ -361,7 +361,6 @@ bool RefCounter::AttemptIncStrong(const void *objectId) if (atomicStrong_.compare_exchange_weak(curCount, curCount + 1, std::memory_order_relaxed)) { break; } - curCount = atomicStrong_.load(std::memory_order_relaxed); } if (curCount <= 0) { DecWeakRefCount(objectId); @@ -510,6 +509,10 @@ void RefBase::IncWeakRef(const void *objectId) refs_->IncWeakRefCount(objectId); } } +RefCounter *RefBase::GetRefCounter() const +{ + return refs_; +} void RefBase::DecWeakRef(const void *objectId) { -- Gitee