diff options
| author | 2010-06-16 01:53:36 -0700 | |
|---|---|---|
| committer | 2010-06-17 13:27:16 -0700 | |
| commit | f4a4ec2063dfd28e04bbfe712f67acee4bdc8e37 (patch) | |
| tree | 9d52c784ebd68acfc44a2cdb06d7cf057bba2c91 /libs/utils/PollLoop.cpp | |
| parent | e85dafb4d625cce230695127c39636a40932b313 (diff) | |
Even more native input dispatch work in progress.
Added more tests.
Fixed a regression in Vector.
Fixed bugs in pointer tracking.
Fixed a starvation issue in PollLoop when setting or removing callbacks.
Fixed a couple of policy nits.
Modified the internal representation of MotionEvent to be more
efficient and more consistent.
Added code to skip/cancel virtual key processing when there are multiple
pointers down. This helps to better disambiguate virtual key presses
from stray touches (such as cheek presses).
Change-Id: I2a7d2cce0195afb9125b23378baa94fd2fc6671c
Diffstat (limited to 'libs/utils/PollLoop.cpp')
| -rw-r--r-- | libs/utils/PollLoop.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/libs/utils/PollLoop.cpp b/libs/utils/PollLoop.cpp index 90a3e8b353..20a4d1385b 100644 --- a/libs/utils/PollLoop.cpp +++ b/libs/utils/PollLoop.cpp @@ -11,7 +11,7 @@ #define DEBUG_POLL_AND_WAKE 0 // Debugs callback registration and invocation. -#define DEBUG_CALLBACKS 1 +#define DEBUG_CALLBACKS 0 #include <cutils/log.h> #include <utils/PollLoop.h> @@ -22,7 +22,7 @@ namespace android { PollLoop::PollLoop() : - mPolling(false) { + mPolling(false), mWaiters(0) { openWakePipe(); } @@ -68,6 +68,9 @@ void PollLoop::closeWakePipe() { bool PollLoop::pollOnce(int timeoutMillis) { mLock.lock(); + while (mWaiters != 0) { + mResume.wait(mLock); + } mPolling = true; mLock.unlock(); @@ -156,7 +159,9 @@ bool PollLoop::pollOnce(int timeoutMillis) { Done: mLock.lock(); mPolling = false; - mAwake.broadcast(); + if (mWaiters != 0) { + mAwake.broadcast(); + } mLock.unlock(); if (result) { @@ -258,10 +263,15 @@ ssize_t PollLoop::getRequestIndexLocked(int fd) { void PollLoop::wakeAndLock() { mLock.lock(); + mWaiters += 1; while (mPolling) { wake(); mAwake.wait(mLock); } + mWaiters -= 1; + if (mWaiters == 0) { + mResume.signal(); + } } } // namespace android |