summaryrefslogtreecommitdiff
path: root/include/utils/Condition.h
diff options
context:
space:
mode:
author Romain Guy <romainguy@google.com> 2013-03-11 14:34:56 -0700
committer Romain Guy <romainguy@google.com> 2013-03-11 14:34:56 -0700
commit9447be65c34b66b01a19a85f4b07bb9c685e847a (patch)
tree9c1d7f892971ad0dfc63b34ff1ce287d554c26ef /include/utils/Condition.h
parent175264b09c6080b29a23fc9f545d4b99445714bd (diff)
Add Thread::isRunning and Condition::signal(WakeUpType)
The signal() method is useful to choose whether to wake up one or all threads. Change-Id: I062ab6d3ddd306a9fb735549ea140e2a76eed75a
Diffstat (limited to 'include/utils/Condition.h')
-rw-r--r--include/utils/Condition.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/utils/Condition.h b/include/utils/Condition.h
index 8852d53330..e63ba7e69c 100644
--- a/include/utils/Condition.h
+++ b/include/utils/Condition.h
@@ -48,6 +48,11 @@ public:
SHARED = 1
};
+ enum WakeUpType {
+ WAKE_UP_ONE = 0,
+ WAKE_UP_ALL = 1
+ };
+
Condition();
Condition(int type);
~Condition();
@@ -57,6 +62,14 @@ public:
status_t waitRelative(Mutex& mutex, nsecs_t reltime);
// Signal the condition variable, allowing one thread to continue.
void signal();
+ // Signal the condition variable, allowing one or all threads to continue.
+ void signal(WakeUpType type) {
+ if (type == WAKE_UP_ONE) {
+ signal();
+ } else {
+ broadcast();
+ }
+ }
// Signal the condition variable, allowing all threads to continue.
void broadcast();