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