GRPC Core  9.0.0
Data Structures | Enumerations | Functions
sync.cc File Reference
#include <grpc/support/port_platform.h>
#include <grpc/support/atm.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include <assert.h>

Data Structures

struct  sync_array_s
 

Enumerations

enum  { event_sync_partitions = 31 }
 

Functions

void gpr_event_init (gpr_event *ev)
 — One-time event notification — More...
 
void gpr_event_set (gpr_event *ev, void *value)
 Set *ev so that gpr_event_get() and gpr_event_wait() will return value. More...
 
void * gpr_event_get (gpr_event *ev)
 Return the value set by gpr_event_set(ev, ...), or NULL if no such call has completed. More...
 
void * gpr_event_wait (gpr_event *ev, gpr_timespec abs_deadline)
 Wait until *ev is set by gpr_event_set(ev, ...), or abs_deadline is exceeded, then return gpr_event_get(ev). More...
 
void gpr_ref_init (gpr_refcount *r, int n)
 — Reference counting — More...
 
void gpr_ref (gpr_refcount *r)
 Increment the reference count *r. More...
 
void gpr_ref_non_zero (gpr_refcount *r)
 Increment the reference count *r. More...
 
void gpr_refn (gpr_refcount *r, int n)
 Increment the reference count *r by n. More...
 
int gpr_unref (gpr_refcount *r)
 Decrement the reference count *r and return non-zero iff it has reached zero. More...
 
int gpr_ref_is_unique (gpr_refcount *r)
 Return non-zero iff the reference count of *r is one, and thus is owned by exactly one object. More...
 
void gpr_stats_init (gpr_stats_counter *c, intptr_t n)
 — Stats counters — More...
 
void gpr_stats_inc (gpr_stats_counter *c, intptr_t inc)
 *c += inc. More...
 
intptr_t gpr_stats_read (const gpr_stats_counter *c)
 Return *c. More...
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
event_sync_partitions 

Function Documentation

◆ gpr_event_get()

void* gpr_event_get ( gpr_event ev)

Return the value set by gpr_event_set(ev, ...), or NULL if no such call has completed.

If the result is non-NULL, all operations that occurred prior to the gpr_event_set(ev, ...) set will be visible after this call returns. Requires: *ev initialized. This operation is faster than acquiring a mutex on most platforms.

◆ gpr_event_init()

void gpr_event_init ( gpr_event ev)

— One-time event notification —

These operations act on a gpr_event, which should be initialized with gpr_ev_init(), or with GPR_EVENT_INIT if static, e.g., static gpr_event event_var = GPR_EVENT_INIT; It requires no destruction.
Initialize *ev.

◆ gpr_event_set()

void gpr_event_set ( gpr_event ev,
void *  value 
)

Set *ev so that gpr_event_get() and gpr_event_wait() will return value.

Requires: *ev initialized; value != NULL; no prior or concurrent calls to gpr_event_set(ev, ...) since initialization.

◆ gpr_event_wait()

void* gpr_event_wait ( gpr_event ev,
gpr_timespec  abs_deadline 
)

Wait until *ev is set by gpr_event_set(ev, ...), or abs_deadline is exceeded, then return gpr_event_get(ev).

Requires: *ev initialized. Use abs_deadline==gpr_inf_future for no deadline. When the event has been signalled before the call, this operation is faster than acquiring a mutex on most platforms.

◆ gpr_ref()

void gpr_ref ( gpr_refcount r)

Increment the reference count *r.

Requires *r initialized.

◆ gpr_ref_init()

void gpr_ref_init ( gpr_refcount r,
int  n 
)

— Reference counting —

These calls act on the type gpr_refcount. It requires no destruction.
Initialize *r to value n.

◆ gpr_ref_is_unique()

int gpr_ref_is_unique ( gpr_refcount r)

Return non-zero iff the reference count of *r is one, and thus is owned by exactly one object.

◆ gpr_ref_non_zero()

void gpr_ref_non_zero ( gpr_refcount r)

Increment the reference count *r.

Requires *r initialized. Crashes if refcount is zero

◆ gpr_refn()

void gpr_refn ( gpr_refcount r,
int  n 
)

Increment the reference count *r by n.

Requires *r initialized, n > 0.

◆ gpr_stats_inc()

void gpr_stats_inc ( gpr_stats_counter c,
intptr_t  inc 
)

*c += inc.

Requires: *c initialized.

◆ gpr_stats_init()

void gpr_stats_init ( gpr_stats_counter c,
intptr_t  n 
)

— Stats counters —

These calls act on the integral type gpr_stats_counter. It requires no destruction. Static instances may be initialized with gpr_stats_counter c = GPR_STATS_INIT; Beware: These operations do not imply memory barriers. Do not use them to synchronize other events.
Initialize *c to the value n.

◆ gpr_stats_read()

intptr_t gpr_stats_read ( const gpr_stats_counter c)

Return *c.

Requires: *c initialized.

◆ gpr_unref()

int gpr_unref ( gpr_refcount r)

Decrement the reference count *r and return non-zero iff it has reached zero.

. Requires *r initialized.