Loading core/java/android/os/ConcurrentMessageQueue/MessageQueue.java +19 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.TestApi; import android.os.Handler; import android.os.Looper; import android.os.Trace; import android.util.Log; import android.util.Printer; Loading Loading @@ -535,6 +536,7 @@ public final class MessageQueue { /* This is only read/written from the Looper thread */ private int mNextPollTimeoutMillis; private static final AtomicLong mMessagesDelivered = new AtomicLong(); private boolean mMessageDirectlyQueued; private Message nextMessage() { int i = 0; Loading Loading @@ -729,6 +731,7 @@ public final class MessageQueue { Binder.flushPendingCommands(); } mMessageDirectlyQueued = false; nativePollOnce(ptr, mNextPollTimeoutMillis); Message msg = nextMessage(); Loading Loading @@ -841,6 +844,22 @@ public final class MessageQueue { + node.isAsync() + " now: " + SystemClock.uptimeMillis()); } final Looper myLooper = Looper.myLooper(); /* If we are running on the looper thread we can add directly to the priority queue */ if (myLooper != null && myLooper.getQueue() == this) { node.removeFromStack(); insertIntoPriorityQueue(node); /* * We still need to do this even though we are the current thread, * otherwise next() may sleep indefinitely. */ if (!mMessageDirectlyQueued) { mMessageDirectlyQueued = true; nativeWake(mPtr); } return true; } while (true) { StackNode old = (StackNode) sState.getVolatile(this); boolean wakeNeeded; Loading Loading
core/java/android/os/ConcurrentMessageQueue/MessageQueue.java +19 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.TestApi; import android.os.Handler; import android.os.Looper; import android.os.Trace; import android.util.Log; import android.util.Printer; Loading Loading @@ -535,6 +536,7 @@ public final class MessageQueue { /* This is only read/written from the Looper thread */ private int mNextPollTimeoutMillis; private static final AtomicLong mMessagesDelivered = new AtomicLong(); private boolean mMessageDirectlyQueued; private Message nextMessage() { int i = 0; Loading Loading @@ -729,6 +731,7 @@ public final class MessageQueue { Binder.flushPendingCommands(); } mMessageDirectlyQueued = false; nativePollOnce(ptr, mNextPollTimeoutMillis); Message msg = nextMessage(); Loading Loading @@ -841,6 +844,22 @@ public final class MessageQueue { + node.isAsync() + " now: " + SystemClock.uptimeMillis()); } final Looper myLooper = Looper.myLooper(); /* If we are running on the looper thread we can add directly to the priority queue */ if (myLooper != null && myLooper.getQueue() == this) { node.removeFromStack(); insertIntoPriorityQueue(node); /* * We still need to do this even though we are the current thread, * otherwise next() may sleep indefinitely. */ if (!mMessageDirectlyQueued) { mMessageDirectlyQueued = true; nativeWake(mPtr); } return true; } while (true) { StackNode old = (StackNode) sState.getVolatile(this); boolean wakeNeeded; Loading