summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2011-12-04 00:45:50 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-12-04 00:45:50 -0800
commit75b95f5bc199acbc42b5b41ca31683ca8ea1b1f9 (patch)
treeb21a43612c5d1debb36d22ccbbd50a5093636c8a /services
parent26f944e7a21b8ac27bd7ed26d9aff4daddb6db73 (diff)
parentbe42aef82f7de3ef04c8c257f882bd6e9653d304 (diff)
downloadframeworks_native-75b95f5bc199acbc42b5b41ca31683ca8ea1b1f9.zip
frameworks_native-75b95f5bc199acbc42b5b41ca31683ca8ea1b1f9.tar.gz
frameworks_native-75b95f5bc199acbc42b5b41ca31683ca8ea1b1f9.tar.bz2
Merge "fix an issue where invalidate/transactions could be missed"
Diffstat (limited to 'services')
-rw-r--r--services/surfaceflinger/MessageQueue.cpp14
-rw-r--r--services/surfaceflinger/MessageQueue.h1
2 files changed, 9 insertions, 6 deletions
diff --git a/services/surfaceflinger/MessageQueue.cpp b/services/surfaceflinger/MessageQueue.cpp
index fdde75c..85845c9 100644
--- a/services/surfaceflinger/MessageQueue.cpp
+++ b/services/surfaceflinger/MessageQueue.cpp
@@ -44,7 +44,7 @@ void MessageBase::handleMessage(const Message&) {
// ---------------------------------------------------------------------------
MessageQueue::MessageQueue()
- : mLooper(new Looper(true))
+ : mLooper(new Looper(true)), mWorkPending(0)
{
}
@@ -58,11 +58,11 @@ void MessageQueue::waitMessage() {
int32_t ret = mLooper->pollOnce(-1);
switch (ret) {
case ALOOPER_POLL_WAKE:
- // we got woken-up there is work to do in the main loop
- return;
-
case ALOOPER_POLL_CALLBACK:
- // callback was handled, loop again
+ // callback and/or wake
+ if (android_atomic_and(0, &mWorkPending)) {
+ return;
+ }
continue;
case ALOOPER_POLL_TIMEOUT:
@@ -94,7 +94,9 @@ status_t MessageQueue::postMessage(
}
status_t MessageQueue::invalidate() {
- mLooper->wake();
+ if (android_atomic_or(1, &mWorkPending) == 0) {
+ mLooper->wake();
+ }
return NO_ERROR;
}
diff --git a/services/surfaceflinger/MessageQueue.h b/services/surfaceflinger/MessageQueue.h
index 775400f..2317d81 100644
--- a/services/surfaceflinger/MessageQueue.h
+++ b/services/surfaceflinger/MessageQueue.h
@@ -55,6 +55,7 @@ private:
class MessageQueue {
sp<Looper> mLooper;
+ volatile int32_t mWorkPending;
public:
MessageQueue();