Loading core/java/android/os/Message.java +4 −1 Original line number Diff line number Diff line Loading @@ -153,8 +153,11 @@ public final class Message implements Parcelable { * The CAS loop shouldn't fail due to FLAG_IN_USE or FLAG_ASYNCHRONOUS being set because those * are only changed when a message is initially created and enqueued. However, we loop anyways * in case additional flags that can be modified are added in the future. * * @hide */ boolean markRemoved() { @VisibleForTesting public boolean markRemoved() { int localFlags; do { localFlags = this.flags; Loading core/java/android/os/MessageStack.java +3 −3 Original line number Diff line number Diff line Loading @@ -215,9 +215,9 @@ public final class MessageStack { } // MessageHeap will maintain its own ordering of Messages, so it doesn't matter that we // insert these Messages in a different order than submitted to the stack. // TODO: Removed messages shouldn't be added to the heap, and possibly not into the // stack either. if (!current.isRemoved()) { getHeap(current).add(current); } current = current.next; } Loading core/tests/coretests/src/android/os/MessageStackTest.java +13 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,19 @@ public final class MessageStackTest { assertEquals(10, stack.sizeForTest()); } /** * Check that the stack doesn't sweep already-removed messages. */ @Test public void testPushRemovedMessage() { MessageStack stack = new MessageStack(); Message m = new Message(); m.markRemoved(); stack.pushMessage(m); stack.heapSweep(); assertEquals(0, stack.combinedHeapSizesForTest()); } /** * Verify quitting state */ Loading Loading
core/java/android/os/Message.java +4 −1 Original line number Diff line number Diff line Loading @@ -153,8 +153,11 @@ public final class Message implements Parcelable { * The CAS loop shouldn't fail due to FLAG_IN_USE or FLAG_ASYNCHRONOUS being set because those * are only changed when a message is initially created and enqueued. However, we loop anyways * in case additional flags that can be modified are added in the future. * * @hide */ boolean markRemoved() { @VisibleForTesting public boolean markRemoved() { int localFlags; do { localFlags = this.flags; Loading
core/java/android/os/MessageStack.java +3 −3 Original line number Diff line number Diff line Loading @@ -215,9 +215,9 @@ public final class MessageStack { } // MessageHeap will maintain its own ordering of Messages, so it doesn't matter that we // insert these Messages in a different order than submitted to the stack. // TODO: Removed messages shouldn't be added to the heap, and possibly not into the // stack either. if (!current.isRemoved()) { getHeap(current).add(current); } current = current.next; } Loading
core/tests/coretests/src/android/os/MessageStackTest.java +13 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,19 @@ public final class MessageStackTest { assertEquals(10, stack.sizeForTest()); } /** * Check that the stack doesn't sweep already-removed messages. */ @Test public void testPushRemovedMessage() { MessageStack stack = new MessageStack(); Message m = new Message(); m.markRemoved(); stack.pushMessage(m); stack.heapSweep(); assertEquals(0, stack.combinedHeapSizesForTest()); } /** * Verify quitting state */ Loading