Go to the documentation of this file.
19 #ifndef GRPCPP_IMPL_SYNC_H
20 #define GRPCPP_IMPL_SYNC_H
24 #ifdef GPR_HAS_PTHREAD_H
33 #include "absl/log/absl_check.h"
34 #include "absl/synchronization/mutex.h"
48 #ifdef GPR_ABSEIL_SYNC
50 using Mutex = absl::Mutex;
51 using MutexLock = absl::MutexLock;
52 using ReleasableMutexLock = absl::ReleasableMutexLock;
53 using CondVar = absl::CondVar;
72 #ifdef GPR_HAS_PTHREAD_H
73 pthread_mutex_t do_not_use_pth_;
101 if (!released_) mu_->Unlock();
108 ABSL_DCHECK(!released_);
115 bool released_ =
false;
137 #endif // GPR_ABSEIL_SYNC
139 template <
typename Predicate>
141 static
void WaitUntil(CondVar* cv, Mutex* mu, Predicate pred) {
150 #endif // GRPCPP_IMPL_SYNC_H
void Unlock() ABSL_UNLOCK_FUNCTION()
Definition: sync.h:66
void Signal()
Definition: sync.h:126
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm.h:33
pthread_mutex_t gpr_mu
Definition: sync_posix.h:43
CondVar & operator=(const CondVar &)=delete
GPRAPI void gpr_mu_destroy(gpr_mu *mu)
Cause *mu no longer to be initialized, freeing any memory in use.
MutexLock(Mutex *mu) ABSL_EXCLUSIVE_LOCK_FUNCTION(mu)
Definition: sync.h:82
GPRAPI int gpr_cv_wait(gpr_cv *cv, gpr_mu *mu, gpr_timespec abs_deadline)
Atomically release *mu and wait on *cv.
GPRAPI gpr_timespec gpr_inf_future(gpr_clock_type type)
The far future.
CondVar()
Definition: sync.h:120
void SignalAll()
Definition: sync.h:127
~Mutex()
Definition: sync.h:60
GPRAPI void gpr_cv_init(gpr_cv *cv)
— Condition variable interface —
GPRAPI void gpr_cv_destroy(gpr_cv *cv)
Cause *cv no longer to be initialized, freeing any memory in use.
GPRAPI void gpr_cv_signal(gpr_cv *cv)
If any threads are waiting on *cv, wake at least one.
pthread_cond_t gpr_cv
Definition: sync_posix.h:44
gpr_mu mu_
Definition: sync.h:70
GPRAPI void gpr_mu_lock(gpr_mu *mu)
Wait until no thread has a lock on *mu, cause the calling thread to own an exclusive lock on *mu,...
GPRAPI void gpr_cv_broadcast(gpr_cv *cv)
Wake all threads waiting on *cv.
GPRAPI void gpr_mu_unlock(gpr_mu *mu)
Release an exclusive lock on *mu held by the calling thread.
~ReleasableMutexLock() ABSL_UNLOCK_FUNCTION()
Definition: sync.h:100
void Wait(Mutex *mu)
Definition: sync.h:129
~CondVar()
Definition: sync.h:121
ReleasableMutexLock(Mutex *mu) ABSL_EXCLUSIVE_LOCK_FUNCTION(mu)
Definition: sync.h:96
void Lock() ABSL_EXCLUSIVE_LOCK_FUNCTION()
Definition: sync.h:65
GPRAPI void gpr_mu_init(gpr_mu *mu)
Synchronization primitives for GPR.
void Release() ABSL_UNLOCK_FUNCTION()
Definition: sync.h:107
std::mutex do_not_use_sth_
Definition: sync.h:71
Mutex()
Definition: sync.h:59
~MutexLock() ABSL_UNLOCK_FUNCTION()
Definition: sync.h:85
@ GPR_CLOCK_REALTIME
Realtime clock.
Definition: time.h:36