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/thread.h b/src/thread.h
index 3ba9f4a..d559449 100644
--- a/src/thread.h
+++ b/src/thread.h
@@ -615,7 +615,7 @@
void InitPthreadKeySelf();
void InitStackHwm();
- void NotifyLocked() EXCLUSIVE_LOCKS_REQUIRED(wait_mutex_);
+ void NotifyLocked(Thread* self) EXCLUSIVE_LOCKS_REQUIRED(wait_mutex_);
bool ReadFlag(ThreadFlag flag) const {
return (state_and_flags_.as_struct.flags & flag) != 0;
@@ -632,8 +632,7 @@
// Used to notify threads that they should attempt to resume, they will suspend again if
// their suspend count is > 0.
- static ConditionVariable* resume_cond_
- GUARDED_BY(Locks::thread_suspend_count_lock_);
+ static ConditionVariable* resume_cond_ GUARDED_BY(Locks::thread_suspend_count_lock_);
// --- Frequently accessed fields first for short offsets ---