summaryrefslogtreecommitdiffstats
path: root/libs/utils
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2013-05-06 14:25:20 -0700
committerDianne Hackborn <hackbod@google.com>2013-05-07 15:05:34 -0700
commitffad7d1fdc8297df8285f16592f6f2ec3cab9828 (patch)
tree1b8e0c6d81346c2a0f30b88d0949fd814248ea87 /libs/utils
parent779434378ee7ca43800a7c7d949c1433c39736fc (diff)
downloadframeworks_native-ffad7d1fdc8297df8285f16592f6f2ec3cab9828.zip
frameworks_native-ffad7d1fdc8297df8285f16592f6f2ec3cab9828.tar.gz
frameworks_native-ffad7d1fdc8297df8285f16592f6f2ec3cab9828.tar.bz2
Add new Looper API to check whether the looper is idle.
This is just to support the watchdog to give it a faster way to determine if a thread is deadlocked without having to post a message to it. Change-Id: I068dc8b9387caf94fe5811fb4aeb0f9b57b1a080
Diffstat (limited to 'libs/utils')
-rw-r--r--libs/utils/Looper.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/libs/utils/Looper.cpp b/libs/utils/Looper.cpp
index a5e6645..c51df2d 100644
--- a/libs/utils/Looper.cpp
+++ b/libs/utils/Looper.cpp
@@ -84,6 +84,8 @@ Looper::Looper(bool allowNonCallbacks) :
LOG_ALWAYS_FATAL_IF(result != 0, "Could not make wake write pipe non-blocking. errno=%d",
errno);
+ mIdling = false;
+
// Allocate the epoll instance and register the wake pipe.
mEpollFd = epoll_create(EPOLL_SIZE_HINT);
LOG_ALWAYS_FATAL_IF(mEpollFd < 0, "Could not create epoll instance. errno=%d", errno);
@@ -214,9 +216,15 @@ int Looper::pollInner(int timeoutMillis) {
mResponses.clear();
mResponseIndex = 0;
+ // We are about to idle.
+ mIdling = true;
+
struct epoll_event eventItems[EPOLL_MAX_EVENTS];
int eventCount = epoll_wait(mEpollFd, eventItems, EPOLL_MAX_EVENTS, timeoutMillis);
+ // No longer idling.
+ mIdling = false;
+
// Acquire lock.
mLock.lock();
@@ -558,4 +566,8 @@ void Looper::removeMessages(const sp<MessageHandler>& handler, int what) {
} // release lock
}
+bool Looper::isIdling() const {
+ return mIdling;
+}
+
} // namespace android