Add gpr_ref_is_unique

pull/9778/head
ncteisen 8 years ago
parent 2f15e9b456
commit 2c94aaeaba
  1. 4
      include/grpc/support/sync.h
  2. 4
      src/core/lib/support/sync.c

@ -164,6 +164,10 @@ GPRAPI void gpr_refn(gpr_refcount *r, int n);
zero. . Requires *r initialized. */
GPRAPI int gpr_unref(gpr_refcount *r);
/* Return non-zero iff the reference count of *r is one, and thus is owned
by exactly one object. */
GPRAPI int gpr_ref_is_unique(gpr_refcount *r);
/* --- Stats counters ---
These calls act on the integral type gpr_stats_counter. It requires no

@ -113,6 +113,10 @@ int gpr_unref(gpr_refcount *r) {
return prior == 1;
}
int gpr_ref_is_unique(gpr_refcount *r) {
return gpr_atm_acq_load(&r->count) == 1;
}
void gpr_stats_init(gpr_stats_counter *c, intptr_t n) {
gpr_atm_rel_store(&c->value, n);
}

Loading…
Cancel
Save