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/mutex_test.cc b/src/mutex_test.cc
index 4dac3c6..0b0f2c9 100644
--- a/src/mutex_test.cc
+++ b/src/mutex_test.cc
@@ -97,13 +97,13 @@
 
 struct RecursiveLockWait {
   explicit RecursiveLockWait()
-      : mu("test mutex", kDefaultMutexLevel, true), cv("test condition variable") {
+      : mu("test mutex", kDefaultMutexLevel, true), cv("test condition variable", mu) {
   }
 
   static void* Callback(void* arg) {
     RecursiveLockWait* state = reinterpret_cast<RecursiveLockWait*>(arg);
     state->mu.Lock(Thread::Current());
-    state->cv.Signal();
+    state->cv.Signal(Thread::Current());
     state->mu.Unlock(Thread::Current());
     return NULL;
   }
@@ -122,7 +122,7 @@
   int pthread_create_result = pthread_create(&pthread, NULL, RecursiveLockWait::Callback, &state);
   ASSERT_EQ(0, pthread_create_result);
 
-  state.cv.Wait(Thread::Current(), state.mu);
+  state.cv.Wait(Thread::Current());
 
   state.mu.Unlock(Thread::Current());
   state.mu.Unlock(Thread::Current());