summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Just <sam.just@inktank.com>2013-05-21 12:47:05 -0700
committerSamuel Just <sam.just@inktank.com>2013-05-21 12:51:20 -0700
commit12eff5d9ff46617f0067a1c57e2b61fc43afb3bb (patch)
treef8f8cc4186161e96ffb3bb7f18911cef0426f277
parentbb64adb7acb4cb32c737a10826183bc87938116d (diff)
downloadceph-12eff5d9ff46617f0067a1c57e2b61fc43afb3bb.tar.gz
common/shared_cache.hpp: add clear()
Clear clears a key/value from the cache. Signed-off-by: Samuel Just <sam.just@inktank.com>
-rw-r--r--src/common/shared_cache.hpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/common/shared_cache.hpp b/src/common/shared_cache.hpp
index 69a4c06dfbf..50da23a4f2f 100644
--- a/src/common/shared_cache.hpp
+++ b/src/common/shared_cache.hpp
@@ -85,6 +85,17 @@ public:
assert(weak_refs.empty());
}
+ void clear(K key) {
+ VPtr val; // release any ref we have after we drop the lock
+ {
+ Mutex::Locker l(lock);
+ if (weak_refs.count(key)) {
+ val = weak_refs[key].lock();
+ }
+ lru_remove(key);
+ }
+ }
+
void set_size(size_t new_size) {
list<VPtr> to_release;
{