summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Mark Fasheh <mfasheh@google.com> 2024-02-29 07:34:22 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-02-29 07:34:22 +0000
commit1f76679133e478af08bb8b1e5bc929517784f36b (patch)
treef5996df2e5ed1280cefc18ffc640bb10318eabdb
parent9d2a1061cf0b5eb0586c23b1d26cd3e7f0d4e247 (diff)
parent62da2f3e03b9d8415475b9e3bf1b5192c7d05e9a (diff)
Merge "MessageQueue tail tracking - fix wakeup logic" into main
-rw-r--r--core/java/android/os/MessageQueue.java10
1 files changed, 6 insertions, 4 deletions
diff --git a/core/java/android/os/MessageQueue.java b/core/java/android/os/MessageQueue.java
index 3950c25675d8..2fe115f49099 100644
--- a/core/java/android/os/MessageQueue.java
+++ b/core/java/android/os/MessageQueue.java
@@ -623,14 +623,14 @@ public final class MessageQueue {
// Message is to be inserted at tail or middle of queue. Usually we don't have to
// wake up the event queue unless there is a barrier at the head of the queue and
// the message is the earliest asynchronous message in the queue.
- //
+ needWake = mBlocked && p.target == null && msg.isAsynchronous();
+
// For readability, we split this portion of the function into two blocks based on
// whether tail tracking is enabled. This has a minor implication for the case
// where tail tracking is disabled. See the comment below.
if (Flags.messageQueueTailTracking()) {
- needWake = mBlocked && p.target == null && msg.isAsynchronous()
- && mAsyncMessageCount == 0;
if (when >= mLast.when) {
+ needWake = needWake && mAsyncMessageCount == 0;
msg.next = null;
mLast.next = msg;
mLast = msg;
@@ -643,6 +643,9 @@ public final class MessageQueue {
if (p == null || when < p.when) {
break;
}
+ if (needWake && p.isAsynchronous()) {
+ needWake = false;
+ }
}
if (p == null) {
/* Inserting at tail of queue */
@@ -652,7 +655,6 @@ public final class MessageQueue {
prev.next = msg;
}
} else {
- needWake = mBlocked && p.target == null && msg.isAsynchronous();
Message prev;
for (;;) {
prev = p;