Loading core/java/android/os/DeliQueue/MessageQueue.java +27 −23 Original line number Diff line number Diff line Loading @@ -317,8 +317,8 @@ public final class MessageQueue { newWaitState = WaitState.incrementCounter(waitState); } else { final long TSmillis = WaitState.getTSMillis(waitState); if (msg.when < TSmillis) { if (msg.when < TSmillis && (!WaitState.hasSyncBarrier(waitState) || msg.isAsynchronous())) { newWaitState = WaitState.initCounter(); needWake = true; } else { Loading Loading @@ -416,6 +416,7 @@ public final class MessageQueue { */ Message next = null; boolean waitingOnSyncBarrier = false; /* * If we have a barrier we should return the async node (if it exists and is ready) */ Loading @@ -423,6 +424,7 @@ public final class MessageQueue { if (asyncMsg != null && (returnEarliest || now >= asyncMsg.when)) { found = asyncMsg; } else { waitingOnSyncBarrier = true; next = asyncMsg; } } else { /* No barrier. */ Loading Loading @@ -513,11 +515,9 @@ public final class MessageQueue { /* * Try to swap waitstate back from a counter to a deadline. If we can't then that means * the counter was incremented and we need to loop back to pick up any new items. * * TODO: Encode sync barrier state here */ if (!sWaitState.compareAndSet(this, oldWaitState, WaitState.composeDeadline(nextDeadline, false))) { WaitState.composeDeadline(nextDeadline, waitingOnSyncBarrier))) { continue; } if (found != null || nextDeadline != 0) { Loading Loading @@ -745,16 +745,21 @@ public final class MessageQueue { + " barrier token has not been posted or has already been removed."); } if (Thread.currentThread() != mLooperThread) { boolean needWake; while (true) { long waitState = mWaitState; long newWaitState; if (WaitState.isCounter(waitState)) { // Thread is already awake and processing messages newWaitState = WaitState.incrementCounter(waitState); needWake = false; } else if (!WaitState.hasSyncBarrier(waitState)) { // Thread is asleep but not waiting on sync barrier newWaitState = WaitState.incrementDeadline(waitState); needWake = false; } else { // Thread is asleep, wake up newWaitState = WaitState.initCounter(); needWake = true; } Loading @@ -767,7 +772,6 @@ public final class MessageQueue { concurrentWake(); } } } /** * Get the timestamp of the next executable message in our priority queue. Loading Loading
core/java/android/os/DeliQueue/MessageQueue.java +27 −23 Original line number Diff line number Diff line Loading @@ -317,8 +317,8 @@ public final class MessageQueue { newWaitState = WaitState.incrementCounter(waitState); } else { final long TSmillis = WaitState.getTSMillis(waitState); if (msg.when < TSmillis) { if (msg.when < TSmillis && (!WaitState.hasSyncBarrier(waitState) || msg.isAsynchronous())) { newWaitState = WaitState.initCounter(); needWake = true; } else { Loading Loading @@ -416,6 +416,7 @@ public final class MessageQueue { */ Message next = null; boolean waitingOnSyncBarrier = false; /* * If we have a barrier we should return the async node (if it exists and is ready) */ Loading @@ -423,6 +424,7 @@ public final class MessageQueue { if (asyncMsg != null && (returnEarliest || now >= asyncMsg.when)) { found = asyncMsg; } else { waitingOnSyncBarrier = true; next = asyncMsg; } } else { /* No barrier. */ Loading Loading @@ -513,11 +515,9 @@ public final class MessageQueue { /* * Try to swap waitstate back from a counter to a deadline. If we can't then that means * the counter was incremented and we need to loop back to pick up any new items. * * TODO: Encode sync barrier state here */ if (!sWaitState.compareAndSet(this, oldWaitState, WaitState.composeDeadline(nextDeadline, false))) { WaitState.composeDeadline(nextDeadline, waitingOnSyncBarrier))) { continue; } if (found != null || nextDeadline != 0) { Loading Loading @@ -745,16 +745,21 @@ public final class MessageQueue { + " barrier token has not been posted or has already been removed."); } if (Thread.currentThread() != mLooperThread) { boolean needWake; while (true) { long waitState = mWaitState; long newWaitState; if (WaitState.isCounter(waitState)) { // Thread is already awake and processing messages newWaitState = WaitState.incrementCounter(waitState); needWake = false; } else if (!WaitState.hasSyncBarrier(waitState)) { // Thread is asleep but not waiting on sync barrier newWaitState = WaitState.incrementDeadline(waitState); needWake = false; } else { // Thread is asleep, wake up newWaitState = WaitState.initCounter(); needWake = true; } Loading @@ -767,7 +772,6 @@ public final class MessageQueue { concurrentWake(); } } } /** * Get the timestamp of the next executable message in our priority queue. Loading