Implement mutex requeueing for cv broadcasts.
Make the mutex guarding a condition variable part of its state. On a
broadcast requeue waiters on the mutex so they are awoken as the mutex
is unlocked (thereby avoiding thundering herds). Explicit futex use
still guarded behind ART_USE_FUTEXES which remains disabled as I'm
unhappy with some of the warts of mutex usage. Uploading so that the API
changes can stabilize.
Change-Id: Iedb601856ccd8bbc3a64da4ba0cee82246e7bcbf
diff --git a/src/signal_catcher.cc b/src/signal_catcher.cc
index b6f6a41..80c37d4 100644
--- a/src/signal_catcher.cc
+++ b/src/signal_catcher.cc
@@ -62,7 +62,7 @@
SignalCatcher::SignalCatcher(const std::string& stack_trace_file)
: stack_trace_file_(stack_trace_file),
lock_("SignalCatcher lock"),
- cond_("SignalCatcher::cond_"),
+ cond_("SignalCatcher::cond_", lock_),
thread_(NULL) {
SetHaltFlag(false);
@@ -72,7 +72,7 @@
Thread* self = Thread::Current();
MutexLock mu(self, lock_);
while (thread_ == NULL) {
- cond_.Wait(self, lock_);
+ cond_.Wait(self);
}
}
@@ -190,7 +190,7 @@
{
MutexLock mu(self, signal_catcher->lock_);
signal_catcher->thread_ = self;
- signal_catcher->cond_.Broadcast();
+ signal_catcher->cond_.Broadcast(self);
}
// Set up mask with signals we want to handle.