Go to the documentation of this file.
58 #ifndef ABSL_SYNCHRONIZATION_MUTEX_H_
59 #define ABSL_SYNCHRONIZATION_MUTEX_H_
65 #include "absl/base/const_init.h"
66 #include "absl/base/internal/identity.h"
67 #include "absl/base/internal/low_level_alloc.h"
68 #include "absl/base/internal/thread_identity.h"
69 #include "absl/base/internal/tsan_mutex_interface.h"
70 #include "absl/base/port.h"
71 #include "absl/base/thread_annotations.h"
72 #include "absl/synchronization/internal/kernel_timeout.h"
73 #include "absl/synchronization/internal/per_thread_sem.h"
74 #include "absl/time/time.h"
80 struct SynchWaitParams;
265 return this->TryLock();
323 this->LockWhen(
cond);
388 return this->LockWhenWithDeadline(
cond, deadline);
408 void EnableInvariantDebugging(
void (*
invariant)(
void *),
void *
arg);
417 void EnableDebugLog(
const char *
name);
426 void ForgetDeadlockInfo();
439 void AssertNotHeld()
const;
460 static void InternalAttemptToUseMutexInFatalSignalHandler();
463 std::atomic<intptr_t>
mu_;
492 void Trans(
MuHow how);
724 template <
typename T,
typename E = decltype(
725 static_cast<bool (
T::*)()
const>(&T::operator()))>
867 std::atomic<intptr_t>
cv_;
885 if (this->
mu_ !=
nullptr) {
893 if (this->
mu_ !=
nullptr) {
899 if (this->
mu_ !=
nullptr) { this->
mu_->Unlock(); }
928 if (this->
mu_ !=
nullptr) { this->
mu_->Unlock(); }
950 template <
typename T>
952 typedef bool (
T::*MemberType)();
953 MemberType
rm =
reinterpret_cast<MemberType
>(c->method_);
954 T *
x =
static_cast<T *
>(c->arg_);
959 template <
typename T>
961 typedef bool (*FuncType)(
T *);
962 FuncType
fn =
reinterpret_cast<FuncType
>(c->function_);
963 T *
x =
static_cast<T *
>(c->arg_);
967 template <
typename T>
969 : eval_(&CastAndCallFunction<
T>),
970 function_(reinterpret_cast<InternalFunctionType>(
func)),
972 arg_(const_cast<void *>(static_cast<
const void *>(
arg))) {}
974 template <
typename T>
977 : eval_(&CastAndCallMethod<
T>),
979 method_(reinterpret_cast<InternalMethodType>(
method)),
982 template <
typename T>
986 : eval_(&CastAndCallMethod<
T>),
988 method_(reinterpret_cast<InternalMethodType>(
method)),
989 arg_(reinterpret_cast<void *>(const_cast<
T *>(object))) {}
1046 ABSL_DEPRECATED(
"absl::RegisterSymbolizer() is deprecated and will be removed "
1047 "on or after 2023-05-01")
1090 #endif // ABSL_SYNCHRONIZATION_MUTEX_H_
ReaderMutexLock(Mutex *mu) ABSL_SHARED_LOCK_FUNCTION(mu)
OPENSSL_EXPORT const ASN1_OBJECT * obj
#define ABSL_ASSERT_SHARED_LOCK(...)
#define WriterMutexLock(x)
bool(* InternalFunctionType)(void *arg)
void RegisterSymbolizer(bool(*fn)(const void *pc, char *out, int out_size))
WriterMutexLock(Mutex *mu, const Condition &cond) ABSL_EXCLUSIVE_LOCK_FUNCTION(mu)
MutexLockMaybe(Mutex *mu, const Condition &cond) ABSL_EXCLUSIVE_LOCK_FUNCTION(mu)
static bool CallVoidPtrFunction(const Condition *)
MutexLock(Mutex *mu, const Condition &cond) ABSL_EXCLUSIVE_LOCK_FUNCTION(mu)
void(* invariant)(void *arg)
std::condition_variable cv_
~WriterMutexLock() ABSL_UNLOCK_FUNCTION()
MutexLock(Mutex *mu) ABSL_EXCLUSIVE_LOCK_FUNCTION(mu)
void WriterUnlock() ABSL_UNLOCK_FUNCTION()
void ABSL_INTERNAL_C_SYMBOL() AbslInternalMutexYield()
void WriterLockWhen(const Condition &cond) ABSL_EXCLUSIVE_LOCK_FUNCTION()
bool(* eval_)(const Condition *)
~ReleasableMutexLock() ABSL_UNLOCK_FUNCTION()
#define ABSL_NAMESPACE_END
std::atomic< intptr_t > mu_
CondVar & operator=(const CondVar &)=delete
#define T(upbtypeconst, upbtype, ctype, default_value)
void Remove(base_internal::PerThreadSynch *s)
void EnableDebugLog(const char *name)
MutexLockMaybe(Mutex *mu) ABSL_EXCLUSIVE_LOCK_FUNCTION(mu)
std::condition_variable Condition
void WriterLock() ABSL_EXCLUSIVE_LOCK_FUNCTION()
ReleasableMutexLock(Mutex *mu) ABSL_EXCLUSIVE_LOCK_FUNCTION(mu)
#define ABSL_NAMESPACE_BEGIN
bool WaitCommon(Mutex *mutex, synchronization_internal::KernelTimeout t)
~MutexLockMaybe() ABSL_UNLOCK_FUNCTION()
#define ABSL_SHARED_TRYLOCK_FUNCTION(...)
#define ABSL_TSAN_MUTEX_CREATE(...)
static bool GuaranteedEqual(const Condition *a, const Condition *b)
#define ABSL_EXCLUSIVE_TRYLOCK_FUNCTION(...)
bool(* InternalMethodCallerType)(void *arg, InternalMethodType internal_method)
ReaderMutexLock(Mutex *mu, const Condition &cond) ABSL_SHARED_LOCK_FUNCTION(mu)
~MutexLock() ABSL_UNLOCK_FUNCTION()
void RegisterMutexTracer(void(*fn)(const char *msg, const void *obj, int64_t wait_cycles))
const struct MuHowS * MuHow
static bool CastAndCallMethod(const Condition *c)
static bool rm(upb_table *t, lookupkey_t key, upb_value *val, upb_tabkey *removed, uint32_t hash, eqlfunc_t *eql)
bool WriterTryLock() ABSL_EXCLUSIVE_TRYLOCK_FUNCTION(true)
#define ABSL_INTERNAL_C_SYMBOL(x)
void RegisterMutexProfiler(void(*fn)(int64_t wait_cycles))
WriterMutexLock(Mutex *mu) ABSL_EXCLUSIVE_LOCK_FUNCTION(mu)
#define ABSL_EXCLUSIVE_LOCK_FUNCTION(...)
static const Condition kTrue
void RegisterCondVarTracer(void(*fn)(const char *msg, const void *cv))
#define ReaderMutexLock(x)
bool WriterLockWhenWithDeadline(const Condition &cond, absl::Time deadline) ABSL_EXCLUSIVE_LOCK_FUNCTION()
~ReaderMutexLock() ABSL_UNLOCK_FUNCTION()
std::atomic< intptr_t > cv_
ReleasableMutexLock(Mutex *mu, const Condition &cond) ABSL_EXCLUSIVE_LOCK_FUNCTION(mu)
#define ABSL_SHARED_LOCK_FUNCTION(...)
bool WaitWithDeadline(Mutex *mu, absl::Time deadline)
#define ABSL_ATTRIBUTE_COLD
#define ABSL_ASSERT_EXCLUSIVE_LOCK(...)
void EnableMutexInvariantDebugging(bool enabled)
bool WriterLockWhenWithTimeout(const Condition &cond, absl::Duration timeout) ABSL_EXCLUSIVE_LOCK_FUNCTION()
Mutex(const volatile Mutex *)
ABSL_DEPRECATED("absl::RegisterSymbolizer() is deprecated and will be removed " "on or after 2023-05-01") void RegisterSymbolizer(bool(*fn)(const void *pc
static bool CastAndCallFunction(const Condition *c)
#define ABSL_UNLOCK_FUNCTION(...)
InternalFunctionType function_
void SetMutexDeadlockDetectionMode(OnDeadlockCycle mode)
bool WaitWithTimeout(Mutex *mu, absl::Duration timeout)
InternalMethodType method_
#define ABSL_SCOPED_LOCKABLE
bool(Condition::* InternalMethodType)()
void Wakeup(base_internal::PerThreadSynch *w)
grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:31