|
|
|
@ -39,9 +39,7 @@ namespace grpc_core { |
|
|
|
|
|
|
|
|
|
// PolymorphicRefCount enforces polymorphic destruction of RefCounted.
|
|
|
|
|
class PolymorphicRefCount { |
|
|
|
|
protected: |
|
|
|
|
GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE |
|
|
|
|
|
|
|
|
|
public: |
|
|
|
|
virtual ~PolymorphicRefCount() = default; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -49,9 +47,7 @@ class PolymorphicRefCount { |
|
|
|
|
// RefCounted. Please refer to grpc_core::RefCounted for more details, and
|
|
|
|
|
// when in doubt use PolymorphicRefCount.
|
|
|
|
|
class NonPolymorphicRefCount { |
|
|
|
|
protected: |
|
|
|
|
GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE |
|
|
|
|
|
|
|
|
|
public: |
|
|
|
|
~NonPolymorphicRefCount() = default; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -230,6 +226,9 @@ class RefCount { |
|
|
|
|
template <typename Child, typename Impl = PolymorphicRefCount> |
|
|
|
|
class RefCounted : public Impl { |
|
|
|
|
public: |
|
|
|
|
// Note: Depending on the Impl used, this dtor can be implicitly virtual.
|
|
|
|
|
~RefCounted() = default; |
|
|
|
|
|
|
|
|
|
RefCountedPtr<Child> Ref() GRPC_MUST_USE_RESULT { |
|
|
|
|
IncrementRefCount(); |
|
|
|
|
return RefCountedPtr<Child>(static_cast<Child*>(this)); |
|
|
|
@ -266,8 +265,6 @@ class RefCounted : public Impl { |
|
|
|
|
RefCounted& operator=(const RefCounted&) = delete; |
|
|
|
|
|
|
|
|
|
protected: |
|
|
|
|
GRPC_ALLOW_CLASS_TO_USE_NON_PUBLIC_DELETE |
|
|
|
|
|
|
|
|
|
// TraceFlagT is defined to accept both DebugOnlyTraceFlag and TraceFlag.
|
|
|
|
|
// Note: RefCount tracing is only enabled on debug builds, even when a
|
|
|
|
|
// TraceFlag is used.
|
|
|
|
@ -276,9 +273,6 @@ class RefCounted : public Impl { |
|
|
|
|
intptr_t initial_refcount = 1) |
|
|
|
|
: refs_(initial_refcount, trace_flag) {} |
|
|
|
|
|
|
|
|
|
// Note: Depending on the Impl used, this dtor can be implicitly virtual.
|
|
|
|
|
~RefCounted() = default; |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
// Allow RefCountedPtr<> to access IncrementRefCount().
|
|
|
|
|
template <typename T> |
|
|
|
|