19 #ifndef GRPC_CORE_LIB_GPRPP_REF_COUNTED_H
20 #define GRPC_CORE_LIB_GPRPP_REF_COUNTED_H
74 if (trace_ !=
nullptr) {
85 if (trace_ !=
nullptr) {
87 trace_,
this, location.
file(), location.
line(), prior, prior + n,
102 if (trace_ !=
nullptr) {
114 if (trace_ !=
nullptr) {
116 trace_,
this, location.
file(), location.
line(), prior, prior + 1,
130 if (trace_ !=
nullptr) {
131 const Value prior = get();
133 trace_,
this, prior, prior + 1);
140 if (trace_ !=
nullptr) {
141 const Value prior = get();
143 "%s:%p %s:%d ref_if_non_zero %" PRIdPTR
" -> %" PRIdPTR
" %s",
144 trace_,
this, location.
file(), location.
line(), prior, prior + 1,
160 auto* trace = trace_;
164 if (trace !=
nullptr) {
165 gpr_log(
GPR_INFO,
"%s:%p unref %" PRIdPTR
" -> %" PRIdPTR, trace,
this,
177 auto* trace = trace_;
181 if (trace !=
nullptr) {
183 trace,
this, location.
file(), location.
line(), prior, prior - 1,
201 Atomic<Value> value_;
235 template <
typename T, UnrefBehavior UnrefBehaviorArg>
237 template <
typename T>
242 template <
typename T>
247 template <
typename T>
280 template <
typename Child,
typename Impl = PolymorphicRefCount,
294 IncrementRefCount(location, reason);
320 ?
static_cast<Child*
>(
this)
331 intptr_t initial_refcount = 1)
332 : refs_(initial_refcount, trace) {}
336 template <
typename T>
339 void IncrementRefCount() { refs_.
Ref(); }
340 void IncrementRefCount(
const DebugLocation& location,
const char* reason) {
341 refs_.
Ref(location, reason);
bool IncrementIfNonzero()
Definition: atomic.h:84
T FetchSub(Arg arg, MemoryOrder order=MemoryOrder::SEQ_CST)
Definition: atomic.h:77
T Load(MemoryOrder order) const
Definition: atomic.h:44
T FetchAdd(Arg arg, MemoryOrder order=MemoryOrder::SEQ_CST)
Definition: atomic.h:71
Definition: debug_location.h:31
int line() const
Definition: debug_location.h:35
const char * file() const
Definition: debug_location.h:34
Definition: ref_counted.h:213
~NonPolymorphicRefCount()=default
Definition: ref_counted.h:205
virtual ~PolymorphicRefCount()=default
Definition: ref_counted.h:47
void Ref(Value n=1)
Definition: ref_counted.h:71
void RefNonZero()
Definition: ref_counted.h:99
intptr_t Value
Definition: ref_counted.h:49
bool RefIfNonZero(const DebugLocation &location, const char *reason)
Definition: ref_counted.h:138
bool Unref(const DebugLocation &location, const char *reason)
Definition: ref_counted.h:172
RefCount(Value init=1, const char *trace=nullptr)
Definition: ref_counted.h:55
void Ref(const DebugLocation &location, const char *reason, Value n=1)
Definition: ref_counted.h:82
bool Unref()
Definition: ref_counted.h:155
bool RefIfNonZero()
Definition: ref_counted.h:128
void RefNonZero(const DebugLocation &location, const char *reason)
Definition: ref_counted.h:111
Definition: ref_counted.h:282
RefCountedPtr< Child > RefIfNonZero(const DebugLocation &location, const char *reason) GRPC_MUST_USE_RESULT
Definition: ref_counted.h:317
RefCountedPtr< Child > Ref() GRPC_MUST_USE_RESULT
Definition: ref_counted.h:287
RefCounted(const char *trace=nullptr, intptr_t initial_refcount=1)
Definition: ref_counted.h:330
RefCounted(const RefCounted &)=delete
void Unref()
Definition: ref_counted.h:302
RefCountedPtr< Child > RefIfNonZero() GRPC_MUST_USE_RESULT
Definition: ref_counted.h:313
RefCountedPtr< Child > Ref(const DebugLocation &location, const char *reason) GRPC_MUST_USE_RESULT
Definition: ref_counted.h:292
void Unref(const DebugLocation &location, const char *reason)
Definition: ref_counted.h:307
RefCounted & operator=(const RefCounted &)=delete
Definition: ref_counted_ptr.h:35
Delete(T *t)
Definition: ref_counted.h:250
Delete(T *t)
Definition: ref_counted.h:240
Delete(T *)
Definition: ref_counted.h:245
Definition: ref_counted.h:236
#define GPR_DEBUG_ASSERT(x)
Definition: log.h:101
GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format,...) GPR_PRINT_FORMAT_CHECK(4
Log a message.
#define GPR_INFO
Definition: log.h:54
Round Robin Policy.
Definition: backend_metric.cc:26
UnrefBehavior
Definition: ref_counted.h:219
@ kUnrefNoDelete
Definition: ref_counted.h:227
@ kUnrefCallDtor
Definition: ref_counted.h:231
@ kUnrefDelete
Definition: ref_counted.h:221