diff options
author | 2022-09-06 02:51:35 +0000 | |
---|---|---|
committer | 2022-09-14 02:32:27 +0000 | |
commit | 474c1674ee543f4508800ac12e4928fa761594dd (patch) | |
tree | 603597073b352acfd67f84fd67e058fec4add874 | |
parent | 887cda512303515a8ddadf10c9f45008a975bf16 (diff) |
[Optimization] It's no need to start the dispatch cycle going if the outbound queue was not previously empty.
If the outbound queue was not previpusly empty, it indicates that the connection's pipe is full.We will try start the next dispatch cycle for this connection in "doDispatchCycleFinishedCommand".
This follows "enqueueDispatchEntriesLocked".
Change-Id: I7736c2bfdb13c35a51b74c46ada7b0f562fecfd9
Merged-In: I7736c2bfdb13c35a51b74c46ada7b0f562fecfd9
-rw-r--r-- | services/inputflinger/dispatcher/InputDispatcher.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp index 5e9427ad87..564acc09f9 100644 --- a/services/inputflinger/dispatcher/InputDispatcher.cpp +++ b/services/inputflinger/dispatcher/InputDispatcher.cpp @@ -3640,6 +3640,8 @@ void InputDispatcher::synthesizeCancelationEventsForConnectionLocked( target.inputChannel = connection->inputChannel; target.flags = InputTarget::FLAG_DISPATCH_AS_IS; + const bool wasEmpty = connection->outboundQueue.empty(); + for (size_t i = 0; i < cancelationEvents.size(); i++) { std::unique_ptr<EventEntry> cancelationEventEntry = std::move(cancelationEvents[i]); switch (cancelationEventEntry->type) { @@ -3674,7 +3676,10 @@ void InputDispatcher::synthesizeCancelationEventsForConnectionLocked( InputTarget::FLAG_DISPATCH_AS_IS); } - startDispatchCycleLocked(currentTime, connection); + // If the outbound queue was previously empty, start the dispatch cycle going. + if (wasEmpty && !connection->outboundQueue.empty()) { + startDispatchCycleLocked(currentTime, connection); + } } void InputDispatcher::synthesizePointerDownEventsForConnectionLocked( @@ -3708,6 +3713,8 @@ void InputDispatcher::synthesizePointerDownEventsForConnectionLocked( target.inputChannel = connection->inputChannel; target.flags = InputTarget::FLAG_DISPATCH_AS_IS; + const bool wasEmpty = connection->outboundQueue.empty(); + for (std::unique_ptr<EventEntry>& downEventEntry : downEvents) { switch (downEventEntry->type) { case EventEntry::Type::MOTION: { @@ -3733,8 +3740,10 @@ void InputDispatcher::synthesizePointerDownEventsForConnectionLocked( enqueueDispatchEntryLocked(connection, std::move(downEventEntry), target, InputTarget::FLAG_DISPATCH_AS_IS); } - - startDispatchCycleLocked(currentTime, connection); + // If the outbound queue was previously empty, start the dispatch cycle going. + if (wasEmpty && !connection->outboundQueue.empty()) { + startDispatchCycleLocked(currentTime, connection); + } } std::unique_ptr<MotionEntry> InputDispatcher::splitMotionEvent( |