diff options
author | Craig Tiller <ctiller@google.com> | 2017-03-01 11:28:24 -0800 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2017-03-01 11:28:24 -0800 |
commit | 295df6da9aa8f6a51cd050ddf92f047d9179d9f2 (patch) | |
tree | 00e458067b742aeabd880906c2517b725f5abd9a /src/core/lib/support | |
parent | 6517333d17e9c16e9f637320dc938b84dd248cc8 (diff) |
Add a slice type that shares a refcount with a transport stream
Diffstat (limited to 'src/core/lib/support')
-rw-r--r-- | src/core/lib/support/sync.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/core/lib/support/sync.c b/src/core/lib/support/sync.c index 44b83f8175..e4a7fce646 100644 --- a/src/core/lib/support/sync.c +++ b/src/core/lib/support/sync.c @@ -37,6 +37,8 @@ #include <grpc/support/log.h> #include <grpc/support/sync.h> +#include <assert.h> + /* Number of mutexes to allocate for events, to avoid lock contention. Should be a prime. */ enum { event_sync_partitions = 31 }; @@ -99,8 +101,12 @@ void gpr_ref_init(gpr_refcount *r, int n) { gpr_atm_rel_store(&r->count, n); } void gpr_ref(gpr_refcount *r) { gpr_atm_no_barrier_fetch_add(&r->count, 1); } void gpr_ref_non_zero(gpr_refcount *r) { +#ifndef NDEBUG gpr_atm prior = gpr_atm_no_barrier_fetch_add(&r->count, 1); - GPR_ASSERT(prior > 0); + assert(prior > 0); +#else + gpr_ref(r); +#endif } void gpr_refn(gpr_refcount *r, int n) { |