summaryrefslogtreecommitdiffstats
path: root/libs/utils
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2009-09-09 02:38:13 -0700
committerMathias Agopian <mathias@google.com>2009-09-09 02:45:26 -0700
commit4de4ebf6a25b5cf1819809ffcedea331d79823e0 (patch)
tree39c110d7cae1d3690c7454be7b3379dd58ceab80 /libs/utils
parent454ea681398a23a45e2a9c4f3b12d7c30fec8e3c (diff)
downloadframeworks_native-4de4ebf6a25b5cf1819809ffcedea331d79823e0.zip
frameworks_native-4de4ebf6a25b5cf1819809ffcedea331d79823e0.tar.gz
frameworks_native-4de4ebf6a25b5cf1819809ffcedea331d79823e0.tar.bz2
use broadcast() instead of signal() when signaling the condition-variable Thread::RequestExitAndWait() is waiting for
we could have several thread waiting on the condition and they all need to wake-up. also added a debug "mTid" field in the class, which contains the tid of the thread (as opposed to pthread_t), this is useful when debugging under gdb for instance.
Diffstat (limited to 'libs/utils')
-rw-r--r--libs/utils/Threads.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/libs/utils/Threads.cpp b/libs/utils/Threads.cpp
index 6be372c..ec3db09 100644
--- a/libs/utils/Threads.cpp
+++ b/libs/utils/Threads.cpp
@@ -655,6 +655,11 @@ int Thread::_threadLoop(void* user)
wp<Thread> weak(strong);
self->mHoldSelf.clear();
+#if HAVE_ANDROID_OS
+ // this is very useful for debugging with gdb
+ self->mTid = gettid();
+#endif
+
bool first = true;
do {
@@ -685,7 +690,7 @@ int Thread::_threadLoop(void* user)
self->mExitPending = true;
self->mLock.lock();
self->mRunning = false;
- self->mThreadExitedCondition.signal();
+ self->mThreadExitedCondition.broadcast();
self->mLock.unlock();
break;
}
@@ -693,7 +698,7 @@ int Thread::_threadLoop(void* user)
// Release our strong reference, to let a chance to the thread
// to die a peaceful death.
strong.clear();
- // And immediately, reacquire a strong reference for the next loop
+ // And immediately, re-acquire a strong reference for the next loop
strong = weak.promote();
} while(strong != 0);