From 6644e5bbbd39bcdd2a33ff7c08d2663a65279e9c Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Fri, 8 Sep 2023 06:55:29 -0700 Subject: absl: remove leftovers of CondVar support for other mutexes When CondVar accepted generic non-Mutex mutexes, Mutex pointer could be nullptr. Now that support is removed, but we still have some lingering checks for Mutex* == nullptr. Remove them. PiperOrigin-RevId: 563740239 Change-Id: Ib744e0b991f411dd8dba1b0da6477c13832e0f65 --- absl/synchronization/mutex.cc | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) (limited to 'absl/synchronization/mutex.cc') diff --git a/absl/synchronization/mutex.cc b/absl/synchronization/mutex.cc index d63ec5ec..8148fbde 100644 --- a/absl/synchronization/mutex.cc +++ b/absl/synchronization/mutex.cc @@ -579,31 +579,25 @@ static SynchLocksHeld* Synch_GetAllLocks() { // Post on "w"'s associated PerThreadSem. void Mutex::IncrementSynchSem(Mutex* mu, PerThreadSynch* w) { - if (mu) { - ABSL_TSAN_MUTEX_PRE_DIVERT(mu, 0); - // We miss synchronization around passing PerThreadSynch between threads - // since it happens inside of the Mutex code, so we need to ignore all - // accesses to the object. - ABSL_ANNOTATE_IGNORE_READS_AND_WRITES_BEGIN(); - PerThreadSem::Post(w->thread_identity()); - ABSL_ANNOTATE_IGNORE_READS_AND_WRITES_END(); - ABSL_TSAN_MUTEX_POST_DIVERT(mu, 0); - } else { - PerThreadSem::Post(w->thread_identity()); - } + static_cast(mu); // Prevent unused param warning in non-TSAN builds. + ABSL_TSAN_MUTEX_PRE_DIVERT(mu, 0); + // We miss synchronization around passing PerThreadSynch between threads + // since it happens inside of the Mutex code, so we need to ignore all + // accesses to the object. + ABSL_ANNOTATE_IGNORE_READS_AND_WRITES_BEGIN(); + PerThreadSem::Post(w->thread_identity()); + ABSL_ANNOTATE_IGNORE_READS_AND_WRITES_END(); + ABSL_TSAN_MUTEX_POST_DIVERT(mu, 0); } // Wait on "w"'s associated PerThreadSem; returns false if timeout expired. bool Mutex::DecrementSynchSem(Mutex* mu, PerThreadSynch* w, KernelTimeout t) { - if (mu) { - ABSL_TSAN_MUTEX_PRE_DIVERT(mu, 0); - } + static_cast(mu); // Prevent unused param warning in non-TSAN builds. + ABSL_TSAN_MUTEX_PRE_DIVERT(mu, 0); assert(w == Synch_GetPerThread()); static_cast(w); bool res = PerThreadSem::Wait(t); - if (mu) { - ABSL_TSAN_MUTEX_POST_DIVERT(mu, 0); - } + ABSL_TSAN_MUTEX_POST_DIVERT(mu, 0); return res; } @@ -2582,7 +2576,7 @@ bool CondVar::WaitCommon(Mutex* mutex, KernelTimeout t) { // Otherwise, if it was not a Mutex mutex, w will be waiting on w->sem // Otherwise, w is transferred to the Mutex mutex via Mutex::Fer(). void CondVar::Wakeup(PerThreadSynch* w) { - if (w->waitp->timeout.has_timeout() || w->waitp->cvmu == nullptr) { + if (w->waitp->timeout.has_timeout()) { // The waiting thread only needs to observe "w->state == kAvailable" to be // released, we must cache "cvmu" before clearing "next". Mutex* mu = w->waitp->cvmu; -- cgit v1.2.3