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

Commit 1adee11b authored by Jeff Brown's avatar Jeff Brown
Browse files

Optimize dispatcher for back-to-back finished signals.

Minor tweak to the dispatcher to handle as many finished signals
in a receive callback as possible instead of going back to
the Looper and waiting for the next poll() to hit the callback
again.

This is part of a series of changes to improve input system pipelining.

Bug: 5963420

Change-Id: I8471107371693e21ce8ce7cca1e8d79ba4ca2351
parent d1c48a05
Loading
Loading
Loading
Loading
+20 −8
Original line number Diff line number Diff line
@@ -2043,18 +2043,30 @@ int InputDispatcher::handleReceiveCallback(int fd, int events, void* data) {
                return 1;
            }

            bool handled = false;
            status_t status = connection->inputPublisher.receiveFinishedSignal(&handled);
            if (!status) {
            nsecs_t currentTime = now();
            bool gotOne = false;
            status_t status;
            for (;;) {
                bool handled = false;
                status = connection->inputPublisher.receiveFinishedSignal(&handled);
                if (status) {
                    break;
                }
                d->finishDispatchCycleLocked(currentTime, connection, handled);
                gotOne = true;
            }
            if (gotOne) {
                d->runCommandsLockedInterruptible();
                if (status == WOULD_BLOCK) {
                    return 1;
                }
            }

            notify = status != DEAD_OBJECT || !connection->monitor;
            if (notify) {
                ALOGE("channel '%s' ~ Failed to receive finished signal.  status=%d",
                        connection->getInputChannelName(), status);
            notify = true;
            }
        } else {
            // Monitor channels are never explicitly unregistered.
            // We do it automatically when the remote endpoint is closed so don't warn