Commit 6644e5bb by Abseil Team Committed by Copybara-Service

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
parent 1cf6469b
...@@ -579,7 +579,7 @@ static SynchLocksHeld* Synch_GetAllLocks() { ...@@ -579,7 +579,7 @@ static SynchLocksHeld* Synch_GetAllLocks() {
// Post on "w"'s associated PerThreadSem. // Post on "w"'s associated PerThreadSem.
void Mutex::IncrementSynchSem(Mutex* mu, PerThreadSynch* w) { void Mutex::IncrementSynchSem(Mutex* mu, PerThreadSynch* w) {
if (mu) { static_cast<void>(mu); // Prevent unused param warning in non-TSAN builds.
ABSL_TSAN_MUTEX_PRE_DIVERT(mu, 0); ABSL_TSAN_MUTEX_PRE_DIVERT(mu, 0);
// We miss synchronization around passing PerThreadSynch between threads // We miss synchronization around passing PerThreadSynch between threads
// since it happens inside of the Mutex code, so we need to ignore all // since it happens inside of the Mutex code, so we need to ignore all
...@@ -588,22 +588,16 @@ void Mutex::IncrementSynchSem(Mutex* mu, PerThreadSynch* w) { ...@@ -588,22 +588,16 @@ void Mutex::IncrementSynchSem(Mutex* mu, PerThreadSynch* w) {
PerThreadSem::Post(w->thread_identity()); PerThreadSem::Post(w->thread_identity());
ABSL_ANNOTATE_IGNORE_READS_AND_WRITES_END(); ABSL_ANNOTATE_IGNORE_READS_AND_WRITES_END();
ABSL_TSAN_MUTEX_POST_DIVERT(mu, 0); ABSL_TSAN_MUTEX_POST_DIVERT(mu, 0);
} else {
PerThreadSem::Post(w->thread_identity());
}
} }
// Wait on "w"'s associated PerThreadSem; returns false if timeout expired. // Wait on "w"'s associated PerThreadSem; returns false if timeout expired.
bool Mutex::DecrementSynchSem(Mutex* mu, PerThreadSynch* w, KernelTimeout t) { bool Mutex::DecrementSynchSem(Mutex* mu, PerThreadSynch* w, KernelTimeout t) {
if (mu) { static_cast<void>(mu); // Prevent unused param warning in non-TSAN builds.
ABSL_TSAN_MUTEX_PRE_DIVERT(mu, 0); ABSL_TSAN_MUTEX_PRE_DIVERT(mu, 0);
}
assert(w == Synch_GetPerThread()); assert(w == Synch_GetPerThread());
static_cast<void>(w); static_cast<void>(w);
bool res = PerThreadSem::Wait(t); bool res = PerThreadSem::Wait(t);
if (mu) {
ABSL_TSAN_MUTEX_POST_DIVERT(mu, 0); ABSL_TSAN_MUTEX_POST_DIVERT(mu, 0);
}
return res; return res;
} }
...@@ -2582,7 +2576,7 @@ bool CondVar::WaitCommon(Mutex* mutex, KernelTimeout t) { ...@@ -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, 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(). // Otherwise, w is transferred to the Mutex mutex via Mutex::Fer().
void CondVar::Wakeup(PerThreadSynch* w) { 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 // The waiting thread only needs to observe "w->state == kAvailable" to be
// released, we must cache "cvmu" before clearing "next". // released, we must cache "cvmu" before clearing "next".
Mutex* mu = w->waitp->cvmu; Mutex* mu = w->waitp->cvmu;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment