[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".
Test: none
Change-Id: I7736c2bfdb13c35a51b74c46ada7b0f562fecfd9
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index b52e312..f73e907 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -2998,7 +2998,7 @@
ATRACE_NAME(message.c_str());
}
- bool wasEmpty = connection->outboundQueue.empty();
+ const bool wasEmpty = connection->outboundQueue.empty();
// Enqueue dispatch entries for the requested modes.
enqueueDispatchEntryLocked(connection, eventEntry, inputTarget,
@@ -3681,6 +3681,8 @@
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) {
@@ -3715,7 +3717,10 @@
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(
@@ -3747,6 +3752,7 @@
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: {
@@ -3773,7 +3779,10 @@
InputTarget::FLAG_DISPATCH_AS_IS);
}
- startDispatchCycleLocked(downTime, connection);
+ // If the outbound queue was previously empty, start the dispatch cycle going.
+ if (wasEmpty && !connection->outboundQueue.empty()) {
+ startDispatchCycleLocked(downTime, connection);
+ }
}
std::unique_ptr<MotionEntry> InputDispatcher::splitMotionEvent(