Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 75b95f5b authored by Mathias Agopian's avatar Mathias Agopian Committed by Android (Google) Code Review
Browse files

Merge "fix an issue where invalidate/transactions could be missed"

parents 26f944e7 be42aef8
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -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() {
    if (android_atomic_or(1, &mWorkPending) == 0) {
        mLooper->wake();
    }
    return NO_ERROR;
}

+1 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ private:

class MessageQueue {
    sp<Looper> mLooper;
    volatile int32_t mWorkPending;

public:
    MessageQueue();