surfaceflinger: use std::queue for mPendingEvents
Replace Vector by std::queue for mPendingEvents. It is used for
pending hotplug events, which happen rarely and are consumed one by
one quickly by an RT thread. std::queue is likely no better than
std::vector in that scenario, but is more expressive.
Bug: 115738279
Test: boots
Change-Id: Ia906a7f08ecbe6d5534cd6ec42e5af2ac865a911
diff --git a/services/surfaceflinger/Scheduler/EventThread.cpp b/services/surfaceflinger/Scheduler/EventThread.cpp
index fa2b0a6..a75235c 100644
--- a/services/surfaceflinger/Scheduler/EventThread.cpp
+++ b/services/surfaceflinger/Scheduler/EventThread.cpp
@@ -181,7 +181,7 @@
event.header.timestamp = systemTime();
event.hotplug.connected = connected;
- mPendingEvents.add(event);
+ mPendingEvents.push(event);
mCondition.notify_all();
}
@@ -244,11 +244,11 @@
if (!timestamp) {
// no vsync event, see if there are some other event
- eventPending = !mPendingEvents.isEmpty();
+ eventPending = !mPendingEvents.empty();
if (eventPending) {
// we have some other event to dispatch
- *outEvent = mPendingEvents[0];
- mPendingEvents.removeAt(0);
+ *outEvent = mPendingEvents.front();
+ mPendingEvents.pop();
}
}
@@ -384,6 +384,7 @@
result.appendFormat(" %p: count=%d\n", connection.get(),
connection != nullptr ? connection->count : 0);
}
+ result.appendFormat(" other-events-pending: %zu\n", mPendingEvents.size());
}
// ---------------------------------------------------------------------------