diff options
author | Jeff Brown <jeffbrown@google.com> | 2010-09-12 17:15:19 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-09-12 17:15:19 -0700 |
commit | b3787d57fffbb898f4767f7a94031cafe974a0b0 (patch) | |
tree | 305041731ad251326cd7e6c2a98500253ada83f9 /include/utils | |
parent | 2f761760459fe27c8e9f96569bb7f28fc5b58bab (diff) | |
parent | 0f0541e40cfef51eb5c3769e53c1aa853b53aaf6 (diff) | |
download | frameworks_base-b3787d57fffbb898f4767f7a94031cafe974a0b0.zip frameworks_base-b3787d57fffbb898f4767f7a94031cafe974a0b0.tar.gz frameworks_base-b3787d57fffbb898f4767f7a94031cafe974a0b0.tar.bz2 |
am 0f0541e4: am b88102f5: Input dispatcher ANR handling enhancements.
Merge commit '0f0541e40cfef51eb5c3769e53c1aa853b53aaf6'
* commit '0f0541e40cfef51eb5c3769e53c1aa853b53aaf6':
Input dispatcher ANR handling enhancements.
Diffstat (limited to 'include/utils')
-rw-r--r-- | include/utils/PollLoop.h | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/include/utils/PollLoop.h b/include/utils/PollLoop.h index bc616eb..c2dfe5d 100644 --- a/include/utils/PollLoop.h +++ b/include/utils/PollLoop.h @@ -172,22 +172,36 @@ private: void* data; }; - const bool mAllowNonCallbacks; - + const bool mAllowNonCallbacks; // immutable + + int mWakeReadPipeFd; // immutable + int mWakeWritePipeFd; // immutable + + // The lock guards state used to track whether there is a poll() in progress and whether + // there are any other threads waiting in wakeAndLock(). The condition variables + // are used to transfer control among these threads such that all waiters are + // serviced before a new poll can begin. + // The wakeAndLock() method increments mWaiters, wakes the poll, blocks on mAwake + // until mPolling becomes false, then decrements mWaiters again. + // The poll() method blocks on mResume until mWaiters becomes 0, then sets + // mPolling to true, blocks until the poll completes, then resets mPolling to false + // and signals mResume if there are waiters. Mutex mLock; - bool mPolling; - uint32_t mWaiters; - Condition mAwake; - Condition mResume; - - int mWakeReadPipeFd; - int mWakeWritePipeFd; - + bool mPolling; // guarded by mLock + uint32_t mWaiters; // guarded by mLock + Condition mAwake; // guarded by mLock + Condition mResume; // guarded by mLock + + // The next two vectors are only mutated when mPolling is false since they must + // not be changed while the poll() system call is in progress. To mutate these + // vectors, the poll() must first be awoken then the lock acquired. Vector<struct pollfd> mRequestedFds; Vector<RequestedCallback> mRequestedCallbacks; - Vector<PendingCallback> mPendingCallbacks; // used privately by pollOnce - Vector<PendingCallback> mPendingFds; // used privately by pollOnce + // This state is only used privately by pollOnce and does not require a lock since + // it runs on a single thread. + Vector<PendingCallback> mPendingCallbacks; + Vector<PendingCallback> mPendingFds; size_t mPendingFdsPos; void openWakePipe(); |