diff options
author | Igor Murashkin <iam@google.com> | 2014-04-15 22:50:02 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-04-15 22:50:02 +0000 |
commit | 8481765738b404053ad52dcbfb567e813d587043 (patch) | |
tree | 4b90cfd5b9681115fbd7ba38ff77814a54ab2574 /include | |
parent | c9cc643f8b0de8acd365c0caa2a8380c1ca26c1a (diff) | |
parent | db4193833c9f4f45d5627a6cefc730af9b8e5b5a (diff) | |
download | system_core-8481765738b404053ad52dcbfb567e813d587043.zip system_core-8481765738b404053ad52dcbfb567e813d587043.tar.gz system_core-8481765738b404053ad52dcbfb567e813d587043.tar.bz2 |
Merge "libutils: Clarify Condition::signal wakes up exactly one thread"
Diffstat (limited to 'include')
-rw-r--r-- | include/utils/Condition.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/include/utils/Condition.h b/include/utils/Condition.h index e63ba7e..1c99d1a 100644 --- a/include/utils/Condition.h +++ b/include/utils/Condition.h @@ -60,7 +60,7 @@ public: status_t wait(Mutex& mutex); // same with relative timeout status_t waitRelative(Mutex& mutex, nsecs_t reltime); - // Signal the condition variable, allowing one thread to continue. + // Signal the condition variable, allowing exactly one thread to continue. void signal(); // Signal the condition variable, allowing one or all threads to continue. void signal(WakeUpType type) { @@ -132,6 +132,17 @@ inline status_t Condition::waitRelative(Mutex& mutex, nsecs_t reltime) { #endif // HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE } inline void Condition::signal() { + /* + * POSIX says pthread_cond_signal wakes up "one or more" waiting threads. + * However bionic follows the glibc guarantee which wakes up "exactly one" + * waiting thread. + * + * man 3 pthread_cond_signal + * pthread_cond_signal restarts one of the threads that are waiting on + * the condition variable cond. If no threads are waiting on cond, + * nothing happens. If several threads are waiting on cond, exactly one + * is restarted, but it is not specified which. + */ pthread_cond_signal(&mCond); } inline void Condition::broadcast() { |