|
|
|
@ -19,15 +19,48 @@ |
|
|
|
|
#ifndef GRPC_SUPPORT_SYNC_H |
|
|
|
|
#define GRPC_SUPPORT_SYNC_H |
|
|
|
|
|
|
|
|
|
/* Platform-specific type declarations of gpr_mu and gpr_cv. */ |
|
|
|
|
#include <grpc/support/port_platform.h> |
|
|
|
|
|
|
|
|
|
#include <grpc/impl/codegen/gpr_types.h> /* for gpr_timespec */ |
|
|
|
|
#include <grpc/impl/codegen/sync.h> // IWYU pragma: export |
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus |
|
|
|
|
extern "C" { |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/** Synchronization primitives for GPR.
|
|
|
|
|
|
|
|
|
|
The type gpr_mu provides a non-reentrant mutex (lock). |
|
|
|
|
|
|
|
|
|
The type gpr_cv provides a condition variable. |
|
|
|
|
|
|
|
|
|
The type gpr_once provides for one-time initialization. |
|
|
|
|
|
|
|
|
|
The type gpr_event provides one-time-setting, reading, and |
|
|
|
|
waiting of a void*, with memory barriers. |
|
|
|
|
|
|
|
|
|
The type gpr_refcount provides an object reference counter, |
|
|
|
|
with memory barriers suitable to control |
|
|
|
|
object lifetimes. |
|
|
|
|
|
|
|
|
|
The type gpr_stats_counter provides an atomic statistics counter. It |
|
|
|
|
provides no memory barriers. |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
#include <grpc/support/sync_generic.h> // IWYU pragma: export |
|
|
|
|
|
|
|
|
|
#if defined(GPR_CUSTOM_SYNC) |
|
|
|
|
#include <grpc/support/sync_custom.h> // IWYU pragma: export |
|
|
|
|
#elif defined(GPR_ABSEIL_SYNC) |
|
|
|
|
#include <grpc/support/sync_abseil.h> // IWYU pragma: export |
|
|
|
|
#elif defined(GPR_POSIX_SYNC) |
|
|
|
|
#include <grpc/support/sync_posix.h> // IWYU pragma: export |
|
|
|
|
#elif defined(GPR_WINDOWS) |
|
|
|
|
#include <grpc/support/sync_windows.h> // IWYU pragma: export |
|
|
|
|
#else |
|
|
|
|
#error Unable to determine platform for sync |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
/** --- Mutex interface ---
|
|
|
|
|
|
|
|
|
|
At most one thread may hold an exclusive lock on a mutex at any given time. |
|
|
|
|