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

Commit 6569437b authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add Message#clear()" into main

parents a2d6105f 43c450e5
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -3047,7 +3047,7 @@ public final class MessageQueue {
                }
                if (removeMatches) {
                    if (p.removeFromStack()) {
                        msg.recycleUnchecked();
                        msg.clear();
                        decAndTraceMessageCount();
                        if (mMessageCounts.incrementCancelled()) {
                            concurrentWake();
@@ -3086,7 +3086,7 @@ public final class MessageQueue {
            if (compare.compareMessage(msg, h, what, object, r, when)) {
                if (removeMatches) {
                    if (queue.remove(msg)) {
                        msg.recycleUnchecked();
                        msg.clear();
                        decAndTraceMessageCount();
                        found = true;
                    }
+17 −12
Original line number Diff line number Diff line
@@ -333,8 +333,23 @@ public final class Message implements Parcelable {
     */
    @UnsupportedAppUsage
    void recycleUnchecked() {
        // Mark the message as in use while it remains in the recycled object pool.
        // Clear out all other details.
        clear();
        if (!MessageQueue.getUseConcurrent()) {
            synchronized (sPoolSync) {
                if (sPoolSize < MAX_POOL_SIZE) {
                    next = sPool;
                    sPool = this;
                    sPoolSize++;
                }
            }
        }
    }

    /**
     * Clears all Message contents.
     */
    void clear() {
        // Prevent accidental reuse such as if this Message is recycled.
        flags = FLAG_IN_USE;
        what = 0;
        arg1 = 0;
@@ -347,16 +362,6 @@ public final class Message implements Parcelable {
        target = null;
        callback = null;
        data = null;

        if (!MessageQueue.getUseConcurrent()) {
            synchronized (sPoolSync) {
                if (sPoolSize < MAX_POOL_SIZE) {
                    next = sPool;
                    sPool = this;
                    sPoolSize++;
                }
            }
        }
    }

    /**