#ifndef CEPH_LRU_MAP_H
#define CEPH_LRU_MAP_H
-#include "common/Mutex.h"
+#include "common/ceph_mutex.h"
template <class K, class V>
class lru_map {
std::map<K, entry> entries;
std::list<K> entries_lru;
- Mutex lock;
+ ceph::mutex lock = ceph::make_mutex("lru_map::lock");
size_t max;
void _add(const K& key, V& value);
public:
- lru_map(int _max) : lock("lru_map"), max(_max) {}
+ lru_map(int _max) : max(_max) {}
virtual ~lru_map() {}
bool find(const K& key, V& value);
template <class K, class V>
bool lru_map<K, V>::find(const K& key, V& value)
{
- std::lock_guard<Mutex> l(lock);
+ std::lock_guard l(lock);
return _find(key, &value, NULL);
}
template <class K, class V>
bool lru_map<K, V>::find_and_update(const K& key, V *value, UpdateContext *ctx)
{
- std::lock_guard<Mutex> l(lock);
+ std::lock_guard l(lock);
return _find(key, value, ctx);
}
template <class K, class V>
void lru_map<K, V>::add(const K& key, V& value)
{
- std::lock_guard<Mutex> l(lock);
+ std::lock_guard l(lock);
_add(key, value);
}
template <class K, class V>
void lru_map<K, V>::erase(const K& key)
{
- std::lock_guard<Mutex> l(lock);
+ std::lock_guard l(lock);
typename std::map<K, entry>::iterator iter = entries.find(key);
if (iter == entries.end())
return;