summaryrefslogtreecommitdiff
path: root/absl/synchronization
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2023-09-08 06:55:29 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2023-09-08 06:56:19 -0700
commit6644e5bbbd39bcdd2a33ff7c08d2663a65279e9c (patch)
tree54eec8a236d6ead589cc870d8f40e6bb2925c6fd /absl/synchronization
parent1cf6469b372a0ab2787ad95f1ebb611c81b968b3 (diff)
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
Diffstat (limited to 'absl/synchronization')
-rw-r--r--absl/synchronization/mutex.cc32
1 files changed, 13 insertions, 19 deletions
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<void>(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<void>(mu); // Prevent unused param warning in non-TSAN builds.
+ ABSL_TSAN_MUTEX_PRE_DIVERT(mu, 0);
assert(w == Synch_GetPerThread());
static_cast<void>(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;