diff options
author | Craig Tiller <ctiller@google.com> | 2017-10-12 22:47:05 +0000 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2017-10-12 22:47:05 +0000 |
commit | ad059f70f8bccee3ae1a0ef1568c8d89c0c1004d (patch) | |
tree | f03cb8cc3fa1c583993b78027f001f734f0c6384 /include/grpc/support | |
parent | 3f05498663ab48e59acfa6b3bc240a1b27af70e8 (diff) |
Fix threading
Diffstat (limited to 'include/grpc/support')
-rw-r--r-- | include/grpc/support/sync.h | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/include/grpc/support/sync.h b/include/grpc/support/sync.h index fe8a59a5d6..3e3f1925ce 100644 --- a/include/grpc/support/sync.h +++ b/include/grpc/support/sync.h @@ -274,7 +274,23 @@ GPRAPI intptr_t gpr_stats_read(const gpr_stats_counter *c); #endif /* 0 */ #ifdef __cplusplus -} +} // extern "C" + +namespace grpc_core { + +class mu_guard { +public: + mu_guard(gpr_mu *mu) : mu_(mu) { gpr_mu_lock(mu); } + ~mu_guard() { gpr_mu_unlock(mu_); } + + mu_guard(const mu_guard&) = delete; + mu_guard& operator=(const mu_guard&) = delete; + +private: + gpr_mu* const mu_; +}; + +} // namespace grpc_core #endif #endif /* GRPC_SUPPORT_SYNC_H */ |