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

Commit 250af847 authored by Shai Barack's avatar Shai Barack
Browse files

removeSyncBarrier doesn't need to wake up Looper if on Looper thread

If so then it's already awake.

Bug: 427541521
Test: MessageQueueTest#testSyncBarriersWakeup 
Flag: EXEMPT bugfix
Change-Id: I9902590535c36cb52e635c2a36379833c0275580
parent a7416534
Loading
Loading
Loading
Loading
+5 −5
Original line number Original line Diff line number Diff line
@@ -1274,14 +1274,14 @@ public final class MessageQueue {
        final MatchBarrierToken matchBarrierToken = new MatchBarrierToken(token);
        final MatchBarrierToken matchBarrierToken = new MatchBarrierToken(token);


        removed = findOrRemoveMessages(null, 0, null, null, 0, matchBarrierToken, true);
        removed = findOrRemoveMessages(null, 0, null, null, 0, matchBarrierToken, true);
        if (removed) {
        if (!removed) {
            // Wake up next() in case it was sleeping on this barrier.
            // TODO(b/427541521): optimize wakeup logic to only wake up if we are blocked.
            concurrentWake();
        } else {
            throw new IllegalStateException("The specified message queue synchronization "
            throw new IllegalStateException("The specified message queue synchronization "
                    + " barrier token has not been posted or has already been removed.");
                    + " barrier token has not been posted or has already been removed.");
        }
        }
        if (Thread.currentThread() != mLooperThread) {
            // Wake up next() in case it was sleeping on this barrier.
            concurrentWake();
        }
    }
    }


    private void removeSyncBarrierLegacy(int token) {
    private void removeSyncBarrierLegacy(int token) {