diff options
author | Dianne Hackborn | 2013-05-06 16:25:20 -0500 |
---|---|---|
committer | Alex Ray | 2013-07-30 15:57:01 -0500 |
commit | 19159f90020c04ac2f4dcb39424d740f765ed9a3 (patch) | |
tree | 242326311d0ad5ce0d2ce40cfc02f07a222479ae /libs/utils/Looper.cpp | |
parent | d9ad7d8d73918d44d41811e9b4d0cc722dae338d (diff) | |
download | platform-system-core-19159f90020c04ac2f4dcb39424d740f765ed9a3.tar.gz platform-system-core-19159f90020c04ac2f4dcb39424d740f765ed9a3.tar.xz platform-system-core-19159f90020c04ac2f4dcb39424d740f765ed9a3.zip |
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/Looper.cpp')
-rw-r--r-- | libs/utils/Looper.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libs/utils/Looper.cpp b/libs/utils/Looper.cpp index a5e66458c..c51df2d1a 100644 --- a/libs/utils/Looper.cpp +++ b/libs/utils/Looper.cpp | |||
@@ -84,6 +84,8 @@ Looper::Looper(bool allowNonCallbacks) : | |||
84 | LOG_ALWAYS_FATAL_IF(result != 0, "Could not make wake write pipe non-blocking. errno=%d", | 84 | LOG_ALWAYS_FATAL_IF(result != 0, "Could not make wake write pipe non-blocking. errno=%d", |
85 | errno); | 85 | errno); |
86 | 86 | ||
87 | mIdling = false; | ||
88 | |||
87 | // Allocate the epoll instance and register the wake pipe. | 89 | // Allocate the epoll instance and register the wake pipe. |
88 | mEpollFd = epoll_create(EPOLL_SIZE_HINT); | 90 | mEpollFd = epoll_create(EPOLL_SIZE_HINT); |
89 | LOG_ALWAYS_FATAL_IF(mEpollFd < 0, "Could not create epoll instance. errno=%d", errno); | 91 | LOG_ALWAYS_FATAL_IF(mEpollFd < 0, "Could not create epoll instance. errno=%d", errno); |
@@ -214,9 +216,15 @@ int Looper::pollInner(int timeoutMillis) { | |||
214 | mResponses.clear(); | 216 | mResponses.clear(); |
215 | mResponseIndex = 0; | 217 | mResponseIndex = 0; |
216 | 218 | ||
219 | // We are about to idle. | ||
220 | mIdling = true; | ||
221 | |||
217 | struct epoll_event eventItems[EPOLL_MAX_EVENTS]; | 222 | struct epoll_event eventItems[EPOLL_MAX_EVENTS]; |
218 | int eventCount = epoll_wait(mEpollFd, eventItems, EPOLL_MAX_EVENTS, timeoutMillis); | 223 | int eventCount = epoll_wait(mEpollFd, eventItems, EPOLL_MAX_EVENTS, timeoutMillis); |
219 | 224 | ||
225 | // No longer idling. | ||
226 | mIdling = false; | ||
227 | |||
220 | // Acquire lock. | 228 | // Acquire lock. |
221 | mLock.lock(); | 229 | mLock.lock(); |
222 | 230 | ||
@@ -558,4 +566,8 @@ void Looper::removeMessages(const sp<MessageHandler>& handler, int what) { | |||
558 | } // release lock | 566 | } // release lock |
559 | } | 567 | } |
560 | 568 | ||
569 | bool Looper::isIdling() const { | ||
570 | return mIdling; | ||
571 | } | ||
572 | |||
561 | } // namespace android | 573 | } // namespace android |