surfaceflinger: use std::vector for mDisplayEventConnections
Replace SortedVector by std::vector for mDisplayEventConnections.
There are usually a couple dozens of connections. They are created
and destroyed as app processes come and go, and are iterated
frequently.
Semantically, SortedVector is std::set rather than std::vector. But
registerDisplayEventConnection can be made private, and the sole
caller never adds the same connection twice, we choose to replace it
by std::vector. However, we still keep a check in
registerDisplayEventConnection to make sure it is indeed the case
temporarily.
Bug: 115738279
Test: boots
Change-Id: Ie2df1f346cceda272f58f7751b31534171d593ca
diff --git a/services/surfaceflinger/Scheduler/EventThread.h b/services/surfaceflinger/Scheduler/EventThread.h
index 3879ae4..6cf065f 100644
--- a/services/surfaceflinger/Scheduler/EventThread.h
+++ b/services/surfaceflinger/Scheduler/EventThread.h
@@ -24,6 +24,7 @@
#include <mutex>
#include <queue>
#include <thread>
+#include <vector>
#include <android-base/thread_annotations.h>
@@ -32,7 +33,6 @@
#include <private/gui/BitTube.h>
#include <utils/Errors.h>
-#include <utils/SortedVector.h>
// ---------------------------------------------------------------------------
namespace android {
@@ -118,7 +118,6 @@
~EventThread();
sp<BnDisplayEventConnection> createEventConnection() const override;
- status_t registerDisplayEventConnection(const sp<Connection>& connection);
void setVsyncRate(uint32_t count, const sp<Connection>& connection);
void requestNextVsync(const sp<Connection>& connection);
@@ -144,6 +143,8 @@
ResyncWithRateLimitCallback resyncWithRateLimitCallback,
InterceptVSyncsCallback interceptVSyncsCallback, const char* threadName);
+ status_t registerDisplayEventConnection(const sp<Connection>& connection);
+
void threadMain();
Vector<sp<EventThread::Connection>> waitForEventLocked(std::unique_lock<std::mutex>* lock,
DisplayEventReceiver::Event* event)
@@ -168,7 +169,7 @@
mutable std::condition_variable mCondition;
// protected by mLock
- SortedVector<wp<Connection>> mDisplayEventConnections GUARDED_BY(mMutex);
+ std::vector<wp<Connection>> mDisplayEventConnections GUARDED_BY(mMutex);
std::queue<DisplayEventReceiver::Event> mPendingEvents GUARDED_BY(mMutex);
std::array<DisplayEventReceiver::Event, 2> mVSyncEvent GUARDED_BY(mMutex);
bool mUseSoftwareVSync GUARDED_BY(mMutex) = false;