am dbca4a0e: Merge "Add Thread::isRunning and Condition::signal(WakeUpType)" into jb-mr2-dev

* commit 'dbca4a0ee5dac0b2f8d0ed4b1667adbf11363e35':
  Add Thread::isRunning and Condition::signal(WakeUpType)
This commit is contained in:
Romain Guy 2013-03-11 21:39:27 +00:00 committed by Android Git Automerger
commit c75412dcdd
3 changed files with 21 additions and 0 deletions

View File

@ -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();

View File

@ -67,6 +67,9 @@ public:
// Do not call from this object's thread; will return WOULD_BLOCK in that case.
status_t join();
// Indicates whether this thread is running or not.
bool isRunning() const;
#ifdef HAVE_ANDROID_OS
// Return the thread's kernel ID, same as the thread itself calling gettid() or
// androidGetTid(), or -1 if the thread is not running.

View File

@ -875,6 +875,11 @@ status_t Thread::join()
return mStatus;
}
bool Thread::isRunning() const {
Mutex::Autolock _l(mLock);
return mRunning;
}
#ifdef HAVE_ANDROID_OS
pid_t Thread::getTid() const
{