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
30 #include "absl/log/absl_check.h"
31 #include "absl/synchronization/mutex.h"
49 #ifdef GPR_ABSEIL_SYNC
51 using Mutex = absl::Mutex;
52 using MutexLock = absl::MutexLock;
53 using ReleasableMutexLock = absl::ReleasableMutexLock;
54 using CondVar = absl::CondVar;
73 #ifdef GPR_HAS_PTHREAD_H
74 pthread_mutex_t do_not_use_pth_;
102 if (!released_) mu_->Unlock();
109 ABSL_DCHECK(!released_);
116 bool released_ =
false;
138 #endif // GPR_ABSEIL_SYNC
140 template <
typename Predicate>
142 static
void WaitUntil(CondVar* cv, Mutex* mu, Predicate pred) {
151 #endif // GRPCPP_IMPL_SYNC_H
void Unlock() ABSL_UNLOCK_FUNCTION()
Definition: sync.h:67
void Signal()
Definition: sync.h:127
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:44
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:83
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:121
void SignalAll()
Definition: sync.h:128
~Mutex()
Definition: sync.h:61
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:45
gpr_mu mu_
Definition: sync.h:71
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:101
void Wait(Mutex *mu)
Definition: sync.h:130
~CondVar()
Definition: sync.h:122
ReleasableMutexLock(Mutex *mu) ABSL_EXCLUSIVE_LOCK_FUNCTION(mu)
Definition: sync.h:97
void Lock() ABSL_EXCLUSIVE_LOCK_FUNCTION()
Definition: sync.h:66
GPRAPI void gpr_mu_init(gpr_mu *mu)
Synchronization primitives for GPR.
void Release() ABSL_UNLOCK_FUNCTION()
Definition: sync.h:108
std::mutex do_not_use_sth_
Definition: sync.h:72
Mutex()
Definition: sync.h:60
~MutexLock() ABSL_UNLOCK_FUNCTION()
Definition: sync.h:86
@ GPR_CLOCK_REALTIME
Realtime clock.
Definition: time.h:37