Revert "Revert "Allow proxies to be compared.""
This reverts commit 7c238ef97977204a5a5ff65a39f602ceb44ed307.
(originally reverted due to merge conflicts)
Bug: 32172906
Test: hidl_test
Change-Id: I590c60ed529847742dede590e1e9a152a7650da0
diff --git a/transport/include/hidl/ConcurrentMap.h b/transport/include/hidl/ConcurrentMap.h
index 18881f1..cd55ad4 100644
--- a/transport/include/hidl/ConcurrentMap.h
+++ b/transport/include/hidl/ConcurrentMap.h
@@ -50,7 +50,19 @@
return mMap.erase(k);
}
-private:
+ std::unique_lock<std::mutex> lock() { return std::unique_lock<std::mutex>(mMutex); }
+
+ void setLocked(K&& k, V&& v) { mMap[std::forward<K>(k)] = std::forward<V>(v); }
+
+ const V& getLocked(const K& k, const V& def) const {
+ const_iterator iter = mMap.find(k);
+ if (iter == mMap.end()) {
+ return def;
+ }
+ return iter->second;
+ }
+
+ private:
mutable std::mutex mMutex;
std::map<K, V> mMap;
};