@ -21,8 +21,8 @@
# include <cstdint>
# include <cstdint>
# include "absl/log/check.h"
# include "absl/log/check.h"
# include "absl/log/log.h"
# include <grpc/support/log.h>
# include <grpc/support/port_platform.h>
# include <grpc/support/port_platform.h>
# include "src/core/lib/gprpp/debug_location.h"
# include "src/core/lib/gprpp/debug_location.h"
@ -93,8 +93,9 @@ class DualRefCounted : public Impl {
# ifndef NDEBUG
# ifndef NDEBUG
const uint32_t weak_refs = GetWeakRefs ( prev_ref_pair ) ;
const uint32_t weak_refs = GetWeakRefs ( prev_ref_pair ) ;
if ( trace_ ! = nullptr ) {
if ( trace_ ! = nullptr ) {
gpr_log ( GPR_INFO , " %s:%p unref %d -> %d, weak_ref %d -> %d " , trace_ , this ,
LOG ( INFO ) < < trace_ < < " : " < < this < < " unref " < < strong_refs < < " -> "
strong_refs , strong_refs - 1 , weak_refs , weak_refs + 1 ) ;
< < strong_refs - 1 < < " , weak_ref " < < weak_refs < < " -> "
< < weak_refs + 1 ;
}
}
CHECK_GT ( strong_refs , 0u ) ;
CHECK_GT ( strong_refs , 0u ) ;
# endif
# endif
@ -111,9 +112,10 @@ class DualRefCounted : public Impl {
# ifndef NDEBUG
# ifndef NDEBUG
const uint32_t weak_refs = GetWeakRefs ( prev_ref_pair ) ;
const uint32_t weak_refs = GetWeakRefs ( prev_ref_pair ) ;
if ( trace_ ! = nullptr ) {
if ( trace_ ! = nullptr ) {
gpr_log ( GPR_INFO , " %s:%p %s:%d unref %d -> %d, weak_ref %d -> %d) %s " ,
LOG ( INFO ) < < trace_ < < " : " < < this < < " " < < location . file ( ) < < " : "
trace_ , this , location . file ( ) , location . line ( ) , strong_refs ,
< < location . line ( ) < < " unref " < < strong_refs < < " -> "
strong_refs - 1 , weak_refs , weak_refs + 1 , reason ) ;
< < strong_refs - 1 < < " , weak_ref " < < weak_refs < < " -> "
< < weak_refs + 1 < < " ) " < < reason ;
}
}
CHECK_GT ( strong_refs , 0u ) ;
CHECK_GT ( strong_refs , 0u ) ;
# else
# else
@ -135,8 +137,9 @@ class DualRefCounted : public Impl {
# ifndef NDEBUG
# ifndef NDEBUG
const uint32_t weak_refs = GetWeakRefs ( prev_ref_pair ) ;
const uint32_t weak_refs = GetWeakRefs ( prev_ref_pair ) ;
if ( trace_ ! = nullptr ) {
if ( trace_ ! = nullptr ) {
gpr_log ( GPR_INFO , " %s:%p ref_if_non_zero %d -> %d (weak_refs=%d) " ,
LOG ( INFO ) < < trace_ < < " : " < < this < < " ref_if_non_zero " < < strong_refs
trace_ , this , strong_refs , strong_refs + 1 , weak_refs ) ;
< < " -> " < < strong_refs + 1 < < " (weak_refs= " < < weak_refs
< < " ) " ;
}
}
# endif
# endif
if ( strong_refs = = 0 ) return nullptr ;
if ( strong_refs = = 0 ) return nullptr ;
@ -153,10 +156,10 @@ class DualRefCounted : public Impl {
# ifndef NDEBUG
# ifndef NDEBUG
const uint32_t weak_refs = GetWeakRefs ( prev_ref_pair ) ;
const uint32_t weak_refs = GetWeakRefs ( prev_ref_pair ) ;
if ( trace_ ! = nullptr ) {
if ( trace_ ! = nullptr ) {
gpr_log ( GPR_INFO ,
LOG ( INFO ) < < trace_ < < " : " < < this < < " " < < location . file ( ) < < " : "
" %s:%p %s:%d ref_if_non_zero %d -> %d (weak_refs=%d) %s " ,
< < location . line ( ) < < " ref_if_non_zero " < < strong_refs
trace_ , this , location . file ( ) , location . line ( ) , strong_refs ,
< < " -> " < < strong_refs + 1 < < " (weak_refs= " < < weak_refs
strong_refs + 1 , weak_refs , reason ) ;
< < " ) " < < reason ;
}
}
# else
# else
// Avoid unused-parameter warnings for debug-only parameters
// Avoid unused-parameter warnings for debug-only parameters
@ -211,8 +214,8 @@ class DualRefCounted : public Impl {
const uint32_t weak_refs = GetWeakRefs ( prev_ref_pair ) ;
const uint32_t weak_refs = GetWeakRefs ( prev_ref_pair ) ;
const uint32_t strong_refs = GetStrongRefs ( prev_ref_pair ) ;
const uint32_t strong_refs = GetStrongRefs ( prev_ref_pair ) ;
if ( trace ! = nullptr ) {
if ( trace ! = nullptr ) {
gpr_log ( GPR_INFO , " %s:%p weak_unref %d -> %d (refs=%d) " , trace , this ,
LOG ( INFO ) < < trace < < " : " < < this < < " weak_unref " < < weak_refs < < " -> "
weak_refs , weak_refs - 1 , strong_refs ) ;
< < weak_refs - 1 < < " (refs= " < < strong_refs < < " ) " ;
}
}
CHECK_GT ( weak_refs , 0u ) ;
CHECK_GT ( weak_refs , 0u ) ;
# endif
# endif
@ -233,9 +236,9 @@ class DualRefCounted : public Impl {
const uint32_t weak_refs = GetWeakRefs ( prev_ref_pair ) ;
const uint32_t weak_refs = GetWeakRefs ( prev_ref_pair ) ;
const uint32_t strong_refs = GetStrongRefs ( prev_ref_pair ) ;
const uint32_t strong_refs = GetStrongRefs ( prev_ref_pair ) ;
if ( trace ! = nullptr ) {
if ( trace ! = nullptr ) {
gpr_log ( GPR_INFO , " %s:%p %s:%d weak_unref %d -> %d (refs=%d) %s " , trace ,
LOG ( INFO ) < < trace < < " : " < < this < < " " < < location . file ( ) < < " : "
this , location . fi le( ) , location . line ( ) , weak_refs , weak_refs - 1 ,
< < location . lin e ( ) < < " weak_unref " < < weak_refs < < " -> "
strong_refs , reason ) ;
< < weak_refs - 1 < < " (refs= " < < strong_refs < < " ) " < < reason ;
}
}
CHECK_GT ( weak_refs , 0u ) ;
CHECK_GT ( weak_refs , 0u ) ;
# else
# else
@ -298,8 +301,8 @@ class DualRefCounted : public Impl {
const uint32_t weak_refs = GetWeakRefs ( prev_ref_pair ) ;
const uint32_t weak_refs = GetWeakRefs ( prev_ref_pair ) ;
CHECK_NE ( strong_refs , 0u ) ;
CHECK_NE ( strong_refs , 0u ) ;
if ( trace_ ! = nullptr ) {
if ( trace_ ! = nullptr ) {
gpr_log ( GPR_INFO , " %s:%p ref %d -> %d; (weak_refs=%d) " , trace_ , this ,
LOG ( INFO ) < < trace_ < < " : " < < this < < " ref " < < strong_refs < < " -> "
strong_refs , strong_refs + 1 , weak_refs ) ;
< < strong_refs + 1 < < " ; (weak_refs= " < < weak_refs < < " ) " ;
}
}
# else
# else
refs_ . fetch_add ( MakeRefPair ( 1 , 0 ) , std : : memory_order_relaxed ) ;
refs_ . fetch_add ( MakeRefPair ( 1 , 0 ) , std : : memory_order_relaxed ) ;
@ -313,9 +316,10 @@ class DualRefCounted : public Impl {
const uint32_t weak_refs = GetWeakRefs ( prev_ref_pair ) ;
const uint32_t weak_refs = GetWeakRefs ( prev_ref_pair ) ;
CHECK_NE ( strong_refs , 0u ) ;
CHECK_NE ( strong_refs , 0u ) ;
if ( trace_ ! = nullptr ) {
if ( trace_ ! = nullptr ) {
gpr_log ( GPR_INFO , " %s:%p %s:%d ref %d -> %d (weak_refs=%d) %s " , trace_ ,
LOG ( INFO ) < < trace_ < < " : " < < this < < " " < < location . file ( ) < < " : "
this , location . file ( ) , location . line ( ) , strong_refs ,
< < location . line ( ) < < " ref " < < strong_refs < < " -> "
strong_refs + 1 , weak_refs , reason ) ;
< < strong_refs + 1 < < " (weak_refs= " < < weak_refs < < " ) "
< < reason ;
}
}
# else
# else
// Use conditionally-important parameters
// Use conditionally-important parameters
@ -332,8 +336,8 @@ class DualRefCounted : public Impl {
const uint32_t strong_refs = GetStrongRefs ( prev_ref_pair ) ;
const uint32_t strong_refs = GetStrongRefs ( prev_ref_pair ) ;
const uint32_t weak_refs = GetWeakRefs ( prev_ref_pair ) ;
const uint32_t weak_refs = GetWeakRefs ( prev_ref_pair ) ;
if ( trace_ ! = nullptr ) {
if ( trace_ ! = nullptr ) {
gpr_log ( GPR_INFO , " %s:%p weak_ref %d -> %d; (refs=%d) " , trace_ , this ,
LOG ( INFO ) < < trace_ < < " : " < < this < < " weak_ref " < < weak_refs < < " -> "
weak_refs , weak_refs + 1 , strong_refs ) ;
< < weak_refs + 1 < < " ; (refs= " < < strong_refs < < " ) " ;
}
}
if ( strong_refs = = 0 ) CHECK_NE ( weak_refs , 0u ) ;
if ( strong_refs = = 0 ) CHECK_NE ( weak_refs , 0u ) ;
# else
# else
@ -348,9 +352,9 @@ class DualRefCounted : public Impl {
const uint32_t strong_refs = GetStrongRefs ( prev_ref_pair ) ;
const uint32_t strong_refs = GetStrongRefs ( prev_ref_pair ) ;
const uint32_t weak_refs = GetWeakRefs ( prev_ref_pair ) ;
const uint32_t weak_refs = GetWeakRefs ( prev_ref_pair ) ;
if ( trace_ ! = nullptr ) {
if ( trace_ ! = nullptr ) {
gpr_log ( GPR_INFO , " %s:%p %s:%d weak_ref %d -> %d (refs=%d) %s " , trace_ ,
LOG ( INFO ) < < trace_ < < " : " < < this < < " " < < location . file ( ) < < " : "
this , location . fi le( ) , location . line ( ) , weak_refs , weak_refs + 1 ,
< < location . lin e ( ) < < " weak_ref " < < weak_refs < < " -> "
strong_refs , reason ) ;
< < weak_refs + 1 < < " (refs= " < < strong_refs < < " ) " < < reason ;
}
}
if ( strong_refs = = 0 ) CHECK_NE ( weak_refs , 0u ) ;
if ( strong_refs = = 0 ) CHECK_NE ( weak_refs , 0u ) ;
# else
# else