summaryrefslogtreecommitdiffstats
path: root/services/surfaceflinger/MessageQueue.cpp
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2011-12-03 14:47:29 -0800
committerMathias Agopian <mathias@google.com>2011-12-03 14:47:29 -0800
commitbe42aef82f7de3ef04c8c257f882bd6e9653d304 (patch)
tree5cc8a7d99db0dedba55029a2ccfb8574345ee453 /services/surfaceflinger/MessageQueue.cpp
parent222893641184014306a26a9d58690c8415181d12 (diff)
downloadframeworks_native-be42aef82f7de3ef04c8c257f882bd6e9653d304.zip
frameworks_native-be42aef82f7de3ef04c8c257f882bd6e9653d304.tar.gz
frameworks_native-be42aef82f7de3ef04c8c257f882bd6e9653d304.tar.bz2
fix an issue where invalidate/transactions could be missed
Change-Id: I84a1fcba1317b2631f5441de7b7ecd12af5ad022
Diffstat (limited to 'services/surfaceflinger/MessageQueue.cpp')
-rw-r--r--services/surfaceflinger/MessageQueue.cpp14
1 files changed, 8 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;
}