summaryrefslogtreecommitdiffstats
path: root/libs/utils
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2011-07-06 11:37:53 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-07-06 11:37:53 -0700
commit5161eb7b233cf3b806046fd935f248b3844d9bd7 (patch)
tree59ec630bb655b3c66819a8ce35dfa0b0101f7da7 /libs/utils
parent55aaccd7e8e3f5a4b0f4333c6bd2404eeac7bbb1 (diff)
parent697283e9177ee5730bf5c652c3c05d3aa3838ace (diff)
downloadframeworks_base-5161eb7b233cf3b806046fd935f248b3844d9bd7.zip
frameworks_base-5161eb7b233cf3b806046fd935f248b3844d9bd7.tar.gz
frameworks_base-5161eb7b233cf3b806046fd935f248b3844d9bd7.tar.bz2
Merge "Add Thread::join"
Diffstat (limited to 'libs/utils')
-rw-r--r--libs/utils/Threads.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/libs/utils/Threads.cpp b/libs/utils/Threads.cpp
index 71352a8..50312e7 100644
--- a/libs/utils/Threads.cpp
+++ b/libs/utils/Threads.cpp
@@ -846,6 +846,25 @@ status_t Thread::requestExitAndWait()
return mStatus;
}
+status_t Thread::join()
+{
+ Mutex::Autolock _l(mLock);
+ if (mThread == getThreadId()) {
+ LOGW(
+ "Thread (this=%p): don't call join() from this "
+ "Thread object's thread. It's a guaranteed deadlock!",
+ this);
+
+ return WOULD_BLOCK;
+ }
+
+ while (mRunning == true) {
+ mThreadExitedCondition.wait(mLock);
+ }
+
+ return mStatus;
+}
+
bool Thread::exitPending() const
{
Mutex::Autolock _l(mLock);