summaryrefslogtreecommitdiffstats
path: root/libs/utils/Threads.cpp
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
commitbe3c018f8b00738cd7e884058966f82597b8e370 (patch)
tree6f4d3f8e77e1b823447bfb9e4112d284a83128d1 /libs/utils/Threads.cpp
parent7e918860f9d496bf0c4b7e1649216c9209c57850 (diff)
parent58e012d1e37e1272d43c9ff0f56c9b236dd1d7f1 (diff)
downloadframeworks_native-be3c018f8b00738cd7e884058966f82597b8e370.zip
frameworks_native-be3c018f8b00738cd7e884058966f82597b8e370.tar.gz
frameworks_native-be3c018f8b00738cd7e884058966f82597b8e370.tar.bz2
Merge "Add Thread::join"
Diffstat (limited to 'libs/utils/Threads.cpp')
-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);