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/runtime.cc b/src/runtime.cc
index e2e419a..ee8a8c8 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -77,7 +77,7 @@
       resolution_method_(NULL),
       system_class_loader_(NULL),
       threads_being_born_(0),
-      shutdown_cond_(new ConditionVariable("Runtime shutdown")),
+      shutdown_cond_(new ConditionVariable("Runtime shutdown", *Locks::runtime_shutdown_lock_)),
       shutting_down_(false),
       shutting_down_started_(false),
       started_(false),
@@ -120,7 +120,7 @@
     MutexLock mu(self, *Locks::runtime_shutdown_lock_);
     shutting_down_started_ = true;
     while (threads_being_born_ > 0) {
-      shutdown_cond_->Wait(self, *Locks::runtime_shutdown_lock_);
+      shutdown_cond_->Wait(self);
     }
     shutting_down_ = true;
   }
@@ -685,7 +685,7 @@
   DCHECK_GT(threads_being_born_, 0U);
   threads_being_born_--;
   if (shutting_down_started_ && threads_being_born_ == 0) {
-    shutdown_cond_->Broadcast();
+    shutdown_cond_->Broadcast(Thread::Current());
   }
 }