]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/common/simple_cache.hpp
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / common / simple_cache.hpp
index 6e8a452eba91ae53879388a1583be209eb1d024d..07d19a731b1fc1ea5c8a73a34819ee188821582d 100644 (file)
 #ifndef CEPH_SIMPLECACHE_H
 #define CEPH_SIMPLECACHE_H
 
+#include <list>
+#include <map>
+#include <unordered_map>
+#include <utility>
+
 #include "common/ceph_mutex.h"
-#include "include/unordered_map.h"
 
 template <class K, class V, class C = std::less<K>, class H = std::hash<K> >
 class SimpleLRU {
@@ -24,9 +28,9 @@ class SimpleLRU {
   size_t max_size;
   size_t max_bytes = 0;
   size_t total_bytes = 0;
-  ceph::unordered_map<K, typename list<pair<K, V> >::iterator, H> contents;
-  list<pair<K, V> > lru;
-  map<K, V, C> pinned;
+  std::unordered_map<K, typename std::list<std::pair<K, V>>::iterator, H> contents;
+  std::list<std::pair<K, V> > lru;
+  std::map<K, V, C> pinned;
 
   void trim_cache() {
     while (contents.size() > max_size) {
@@ -67,11 +71,10 @@ public:
 
   void clear_pinned(K e) {
     std::lock_guard l(lock);
-    for (typename map<K, V, C>::iterator i = pinned.begin();
+    for (auto i = pinned.begin();
         i != pinned.end() && i->first <= e;
         pinned.erase(i++)) {
-      typename ceph::unordered_map<K, typename list<pair<K, V> >::iterator, H>::iterator iter =
-        contents.find(i->first);
+      auto iter = contents.find(i->first);
       if (iter == contents.end())
        _add(i->first, std::move(i->second));
       else
@@ -81,8 +84,7 @@ public:
 
   void clear(K key) {
     std::lock_guard l(lock);
-    typename ceph::unordered_map<K, typename list<pair<K, V> >::iterator, H>::iterator i =
-      contents.find(key);
+    auto i = contents.find(key);
     if (i == contents.end())
       return;
     total_bytes -= i->second->second.length();
@@ -114,14 +116,13 @@ public:
 
   bool lookup(K key, V *out) {
     std::lock_guard l(lock);
-    typename ceph::unordered_map<K, typename list<pair<K, V> >::iterator, H>::iterator i =
-      contents.find(key);
+    auto i = contents.find(key);
     if (i != contents.end()) {
       *out = i->second->second;
       lru.splice(lru.begin(), lru, i->second);
       return true;
     }
-    typename map<K, V, C>::iterator i_pinned = pinned.find(key);
+    auto i_pinned = pinned.find(key);
     if (i_pinned != pinned.end()) {
       *out = i_pinned->second;
       return true;