Loading core/java/android/os/CombinedMessageQueue/MessageQueue.java +6 −26 Original line number Diff line number Diff line Loading @@ -98,7 +98,6 @@ public final class MessageQueue { @UnsupportedAppUsage private final ArrayList<IdleHandler> mIdleHandlers = new ArrayList<IdleHandler>(); private SparseArray<FileDescriptorRecord> mFileDescriptorRecords; private volatile boolean mHasFileDescriptorRecords; private IdleHandler[] mPendingIdleHandlers; private boolean mQuitting; Loading Loading @@ -585,17 +584,6 @@ public final class MessageQueue { setFileDescriptorEvents(fdNum, 0); } // Indicate to maybePollOnce() if we have file descriptor records that // need to be polled for events. // We write this volatile field here and read it from the worker thread. // Adding an FD on a client thread and polling for events on the worker thread are // inherently racy. If the worker thread skips polling because it thinks there are // no FDs to watch and there is a Message to handle, then the worker will still // poll for the same events the next time. Events won't be missed, they'll just be // interleaved with Message handling in undefined ways. mHasFileDescriptorRecords = mFileDescriptorRecords != null && (mFileDescriptorRecords.size() > 0); } // Called from native code. Loading Loading @@ -865,18 +853,9 @@ public final class MessageQueue { } } private void maybePollOnce(int nextPollTimeoutMillis) { if (!Flags.messageQueueNativePollOnceAndForAll()) { // If nativePollOnce optimization is not in effect, poll unconditionally. nativePollOnce(mPtr, nextPollTimeoutMillis); } else if (nextPollTimeoutMillis != 0 || mHasFileDescriptorRecords || getQuitting()) { // We need to wait for the next message, or we need to poll for file descriptor events. nativePollOnce(mPtr, nextPollTimeoutMillis); } } private Message nextConcurrent() { if (mPtr == 0) { final long ptr = mPtr; if (ptr == 0) { return null; } Loading @@ -888,7 +867,7 @@ public final class MessageQueue { } mMessageDirectlyQueued = false; maybePollOnce(mNextPollTimeoutMillis); nativePollOnce(ptr, mNextPollTimeoutMillis); Message msg = nextMessage(false, false); if (msg != null) { Loading Loading @@ -955,7 +934,8 @@ public final class MessageQueue { // Return here if the message loop has already quit and been disposed. // This can happen if the application tries to restart a looper after quit // which is not supported. if (mPtr == 0) { final long ptr = mPtr; if (ptr == 0) { return null; } Loading @@ -966,7 +946,7 @@ public final class MessageQueue { Binder.flushPendingCommands(); } maybePollOnce(nextPollTimeoutMillis); nativePollOnce(ptr, nextPollTimeoutMillis); synchronized (this) { // Try to retrieve the next message. Return if found. Loading core/java/android/os/ConcurrentMessageQueue/MessageQueue.java +1 −23 Original line number Diff line number Diff line Loading @@ -438,7 +438,6 @@ public final class MessageQueue { private final Object mFileDescriptorRecordsLock = new Object(); @GuardedBy("mFileDescriptorRecordsLock") private SparseArray<FileDescriptorRecord> mFileDescriptorRecords; private volatile boolean mHasFileDescriptorRecords; // The next barrier token. // Barriers are indicated by messages with a null target whose arg1 field carries the token. Loading Loading @@ -886,16 +885,6 @@ public final class MessageQueue { } } private void maybePollOnce(int nextPollTimeoutMillis) { if (!Flags.messageQueueNativePollOnceAndForAll()) { // If nativePollOnce optimization is not in effect, poll unconditionally. nativePollOnce(mPtr, nextPollTimeoutMillis); } else if (nextPollTimeoutMillis != 0 || mHasFileDescriptorRecords || getQuitting()) { // We need to wait for the next message, or we need to poll for file descriptor events. nativePollOnce(mPtr, nextPollTimeoutMillis); } } Message next() { final long ptr = mPtr; if (ptr == 0) { Loading @@ -910,7 +899,7 @@ public final class MessageQueue { } mMessageDirectlyQueued = false; maybePollOnce(mNextPollTimeoutMillis); nativePollOnce(ptr, mNextPollTimeoutMillis); Message msg = nextMessage(false, false); if (msg != null) { Loading Loading @@ -1761,17 +1750,6 @@ public final class MessageQueue { mFileDescriptorRecords.removeAt(index); setFileDescriptorEvents(fdNum, 0); } // Indicate to maybePollOnce() if we have file descriptor records that // need to be polled for events. // We write this volatile field here and read it from the worker thread. // Adding an FD on a client thread and polling for events on the worker thread are // inherently racy. If the worker thread skips polling because it thinks there are // no FDs to watch and there is a Message to handle, then the worker will still // poll for the same events the next time. Events won't be missed, they'll just be // interleaved with Message handling in undefined ways. mHasFileDescriptorRecords = mFileDescriptorRecords != null && (mFileDescriptorRecords.size() > 0); } // Called from native code. Loading core/java/android/os/LegacyMessageQueue/MessageQueue.java +1 −23 Original line number Diff line number Diff line Loading @@ -71,7 +71,6 @@ public final class MessageQueue { @UnsupportedAppUsage private final ArrayList<IdleHandler> mIdleHandlers = new ArrayList<IdleHandler>(); private SparseArray<FileDescriptorRecord> mFileDescriptorRecords; private volatile boolean mHasFileDescriptorRecords; private IdleHandler[] mPendingIdleHandlers; private boolean mQuitting; Loading Loading @@ -327,17 +326,6 @@ public final class MessageQueue { mFileDescriptorRecords.removeAt(index); nativeSetFileDescriptorEvents(mPtr, fdNum, 0); } // Indicate to maybePollOnce() if we have file descriptor records that // need to be polled for events. // We write this volatile field here and read it from the worker thread. // Adding an FD on a client thread and polling for events on the worker thread are // inherently racy. If the worker thread skips polling because it thinks there are // no FDs to watch and there is a Message to handle, then the worker will still // poll for the same events the next time. Events won't be missed, they'll just be // interleaved with Message handling in undefined ways. mHasFileDescriptorRecords = mFileDescriptorRecords != null && (mFileDescriptorRecords.size() > 0); } // Called from native code. Loading Loading @@ -392,16 +380,6 @@ public final class MessageQueue { private static final AtomicLong mMessagesDelivered = new AtomicLong(); private void maybePollOnce(int nextPollTimeoutMillis) { if (!Flags.messageQueueNativePollOnceAndForAll()) { // If nativePollOnce optimization is not in effect, poll unconditionally. nativePollOnce(mPtr, nextPollTimeoutMillis); } else if (nextPollTimeoutMillis != 0 || mHasFileDescriptorRecords) { // We need to wait for the next message, or we need to poll for file descriptor events. nativePollOnce(mPtr, nextPollTimeoutMillis); } } @UnsupportedAppUsage Message next() { // Return here if the message loop has already quit and been disposed. Loading @@ -419,7 +397,7 @@ public final class MessageQueue { Binder.flushPendingCommands(); } maybePollOnce(nextPollTimeoutMillis); nativePollOnce(ptr, nextPollTimeoutMillis); synchronized (this) { // Try to retrieve the next message. Return if found. Loading core/java/android/os/flags.aconfig +0 −8 Original line number Diff line number Diff line Loading @@ -317,14 +317,6 @@ flag { is_exported: true } flag { name: "message_queue_native_poll_once_and_for_all" namespace: "system_performance" description: "Don't call nativePollOnce unnecessarily." bug: "410218466" is_fixed_read_only: false } flag { name: "message_queue_testability" namespace: "system_performance" Loading Loading
core/java/android/os/CombinedMessageQueue/MessageQueue.java +6 −26 Original line number Diff line number Diff line Loading @@ -98,7 +98,6 @@ public final class MessageQueue { @UnsupportedAppUsage private final ArrayList<IdleHandler> mIdleHandlers = new ArrayList<IdleHandler>(); private SparseArray<FileDescriptorRecord> mFileDescriptorRecords; private volatile boolean mHasFileDescriptorRecords; private IdleHandler[] mPendingIdleHandlers; private boolean mQuitting; Loading Loading @@ -585,17 +584,6 @@ public final class MessageQueue { setFileDescriptorEvents(fdNum, 0); } // Indicate to maybePollOnce() if we have file descriptor records that // need to be polled for events. // We write this volatile field here and read it from the worker thread. // Adding an FD on a client thread and polling for events on the worker thread are // inherently racy. If the worker thread skips polling because it thinks there are // no FDs to watch and there is a Message to handle, then the worker will still // poll for the same events the next time. Events won't be missed, they'll just be // interleaved with Message handling in undefined ways. mHasFileDescriptorRecords = mFileDescriptorRecords != null && (mFileDescriptorRecords.size() > 0); } // Called from native code. Loading Loading @@ -865,18 +853,9 @@ public final class MessageQueue { } } private void maybePollOnce(int nextPollTimeoutMillis) { if (!Flags.messageQueueNativePollOnceAndForAll()) { // If nativePollOnce optimization is not in effect, poll unconditionally. nativePollOnce(mPtr, nextPollTimeoutMillis); } else if (nextPollTimeoutMillis != 0 || mHasFileDescriptorRecords || getQuitting()) { // We need to wait for the next message, or we need to poll for file descriptor events. nativePollOnce(mPtr, nextPollTimeoutMillis); } } private Message nextConcurrent() { if (mPtr == 0) { final long ptr = mPtr; if (ptr == 0) { return null; } Loading @@ -888,7 +867,7 @@ public final class MessageQueue { } mMessageDirectlyQueued = false; maybePollOnce(mNextPollTimeoutMillis); nativePollOnce(ptr, mNextPollTimeoutMillis); Message msg = nextMessage(false, false); if (msg != null) { Loading Loading @@ -955,7 +934,8 @@ public final class MessageQueue { // Return here if the message loop has already quit and been disposed. // This can happen if the application tries to restart a looper after quit // which is not supported. if (mPtr == 0) { final long ptr = mPtr; if (ptr == 0) { return null; } Loading @@ -966,7 +946,7 @@ public final class MessageQueue { Binder.flushPendingCommands(); } maybePollOnce(nextPollTimeoutMillis); nativePollOnce(ptr, nextPollTimeoutMillis); synchronized (this) { // Try to retrieve the next message. Return if found. Loading
core/java/android/os/ConcurrentMessageQueue/MessageQueue.java +1 −23 Original line number Diff line number Diff line Loading @@ -438,7 +438,6 @@ public final class MessageQueue { private final Object mFileDescriptorRecordsLock = new Object(); @GuardedBy("mFileDescriptorRecordsLock") private SparseArray<FileDescriptorRecord> mFileDescriptorRecords; private volatile boolean mHasFileDescriptorRecords; // The next barrier token. // Barriers are indicated by messages with a null target whose arg1 field carries the token. Loading Loading @@ -886,16 +885,6 @@ public final class MessageQueue { } } private void maybePollOnce(int nextPollTimeoutMillis) { if (!Flags.messageQueueNativePollOnceAndForAll()) { // If nativePollOnce optimization is not in effect, poll unconditionally. nativePollOnce(mPtr, nextPollTimeoutMillis); } else if (nextPollTimeoutMillis != 0 || mHasFileDescriptorRecords || getQuitting()) { // We need to wait for the next message, or we need to poll for file descriptor events. nativePollOnce(mPtr, nextPollTimeoutMillis); } } Message next() { final long ptr = mPtr; if (ptr == 0) { Loading @@ -910,7 +899,7 @@ public final class MessageQueue { } mMessageDirectlyQueued = false; maybePollOnce(mNextPollTimeoutMillis); nativePollOnce(ptr, mNextPollTimeoutMillis); Message msg = nextMessage(false, false); if (msg != null) { Loading Loading @@ -1761,17 +1750,6 @@ public final class MessageQueue { mFileDescriptorRecords.removeAt(index); setFileDescriptorEvents(fdNum, 0); } // Indicate to maybePollOnce() if we have file descriptor records that // need to be polled for events. // We write this volatile field here and read it from the worker thread. // Adding an FD on a client thread and polling for events on the worker thread are // inherently racy. If the worker thread skips polling because it thinks there are // no FDs to watch and there is a Message to handle, then the worker will still // poll for the same events the next time. Events won't be missed, they'll just be // interleaved with Message handling in undefined ways. mHasFileDescriptorRecords = mFileDescriptorRecords != null && (mFileDescriptorRecords.size() > 0); } // Called from native code. Loading
core/java/android/os/LegacyMessageQueue/MessageQueue.java +1 −23 Original line number Diff line number Diff line Loading @@ -71,7 +71,6 @@ public final class MessageQueue { @UnsupportedAppUsage private final ArrayList<IdleHandler> mIdleHandlers = new ArrayList<IdleHandler>(); private SparseArray<FileDescriptorRecord> mFileDescriptorRecords; private volatile boolean mHasFileDescriptorRecords; private IdleHandler[] mPendingIdleHandlers; private boolean mQuitting; Loading Loading @@ -327,17 +326,6 @@ public final class MessageQueue { mFileDescriptorRecords.removeAt(index); nativeSetFileDescriptorEvents(mPtr, fdNum, 0); } // Indicate to maybePollOnce() if we have file descriptor records that // need to be polled for events. // We write this volatile field here and read it from the worker thread. // Adding an FD on a client thread and polling for events on the worker thread are // inherently racy. If the worker thread skips polling because it thinks there are // no FDs to watch and there is a Message to handle, then the worker will still // poll for the same events the next time. Events won't be missed, they'll just be // interleaved with Message handling in undefined ways. mHasFileDescriptorRecords = mFileDescriptorRecords != null && (mFileDescriptorRecords.size() > 0); } // Called from native code. Loading Loading @@ -392,16 +380,6 @@ public final class MessageQueue { private static final AtomicLong mMessagesDelivered = new AtomicLong(); private void maybePollOnce(int nextPollTimeoutMillis) { if (!Flags.messageQueueNativePollOnceAndForAll()) { // If nativePollOnce optimization is not in effect, poll unconditionally. nativePollOnce(mPtr, nextPollTimeoutMillis); } else if (nextPollTimeoutMillis != 0 || mHasFileDescriptorRecords) { // We need to wait for the next message, or we need to poll for file descriptor events. nativePollOnce(mPtr, nextPollTimeoutMillis); } } @UnsupportedAppUsage Message next() { // Return here if the message loop has already quit and been disposed. Loading @@ -419,7 +397,7 @@ public final class MessageQueue { Binder.flushPendingCommands(); } maybePollOnce(nextPollTimeoutMillis); nativePollOnce(ptr, nextPollTimeoutMillis); synchronized (this) { // Try to retrieve the next message. Return if found. Loading
core/java/android/os/flags.aconfig +0 −8 Original line number Diff line number Diff line Loading @@ -317,14 +317,6 @@ flag { is_exported: true } flag { name: "message_queue_native_poll_once_and_for_all" namespace: "system_performance" description: "Don't call nativePollOnce unnecessarily." bug: "410218466" is_fixed_read_only: false } flag { name: "message_queue_testability" namespace: "system_performance" Loading