From: Sage Weil Date: Thu, 23 Jul 2015 12:46:05 +0000 (-0400) Subject: common/shared_cache: parameterize the map<> comparator X-Git-Tag: v9.1.0~346^2~38 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=332e1a48603a5cc8de3544b1fceaa843213b5c02;p=ceph.git common/shared_cache: parameterize the map<> comparator Signed-off-by: Sage Weil --- diff --git a/src/common/shared_cache.hpp b/src/common/shared_cache.hpp index aaa47f04f371..d149d1ba39a9 100644 --- a/src/common/shared_cache.hpp +++ b/src/common/shared_cache.hpp @@ -22,7 +22,7 @@ #include "common/Mutex.h" #include "common/Cond.h" -template +template > class SharedLRU { CephContext *cct; typedef ceph::shared_ptr VPtr; @@ -34,10 +34,10 @@ class SharedLRU { public: int waiting; private: - map >::iterator > contents; + map >::iterator, C> contents; list > lru; - map > weak_refs; + map, C> weak_refs; void trim_cache(list *to_release) { while (size > max_size) { @@ -47,7 +47,7 @@ private: } void lru_remove(const K& key) { - typename map >::iterator>::iterator i = + typename map >::iterator, C>::iterator i = contents.find(key); if (i == contents.end()) return; @@ -57,7 +57,7 @@ private: } void lru_add(const K& key, const VPtr& val, list *to_release) { - typename map >::iterator>::iterator i = + typename map >::iterator, C>::iterator i = contents.find(key); if (i != contents.end()) { lru.splice(lru.begin(), lru, i->second); @@ -71,7 +71,7 @@ private: void remove(const K& key, V *valptr) { Mutex::Locker l(lock); - typename map >::iterator i = weak_refs.find(key); + typename map, C>::iterator i = weak_refs.find(key); if (i != weak_refs.end() && i->second.second == valptr) { weak_refs.erase(i); } @@ -80,9 +80,9 @@ private: class Cleanup { public: - SharedLRU *cache; + SharedLRU *cache; K key; - Cleanup(SharedLRU *cache, K key) : cache(cache), key(key) {} + Cleanup(SharedLRU *cache, K key) : cache(cache), key(key) {} void operator()(V *ptr) { cache->remove(key, ptr); delete ptr; @@ -116,7 +116,7 @@ public: } void dump_weak_refs(ostream& out) { - for (typename map >::iterator p = weak_refs.begin(); + for (typename map, C>::iterator p = weak_refs.begin(); p != weak_refs.end(); ++p) { out << __func__ << " " << this << " weak_refs: " @@ -188,7 +188,7 @@ public: retry = false; if (weak_refs.empty()) break; - typename map >::iterator i = + typename map, C>::iterator i = weak_refs.lower_bound(key); if (i == weak_refs.end()) --i; @@ -210,7 +210,7 @@ public: { Mutex::Locker l(lock); VPtr next_val; - typename map >::iterator i = weak_refs.upper_bound(key); + typename map, C>::iterator i = weak_refs.upper_bound(key); while (i != weak_refs.end() && !(next_val = i->second.first.lock())) @@ -246,7 +246,7 @@ public: bool retry = false; do { retry = false; - typename map >::iterator i = weak_refs.find(key); + typename map, C>::iterator i = weak_refs.find(key); if (i != weak_refs.end()) { val = i->second.first.lock(); if (val) { @@ -270,7 +270,7 @@ public: bool retry = false; do { retry = false; - typename map >::iterator i = weak_refs.find(key); + typename map, C>::iterator i = weak_refs.find(key); if (i != weak_refs.end()) { val = i->second.first.lock(); if (val) { @@ -320,7 +320,7 @@ public: list to_release; { Mutex::Locker l(lock); - typename map >::iterator actual = + typename map, C>::iterator actual = weak_refs.lower_bound(key); if (actual != weak_refs.end() && actual->first == key) { if (existed)