From 0172069d0fe3a73e3a89330689368e193f72040c Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Wed, 14 Jan 2015 08:29:58 -0800 Subject: [PATCH] common/shared_cache.hpp: restructure clear() Signed-off-by: Samuel Just --- src/common/shared_cache.hpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/common/shared_cache.hpp b/src/common/shared_cache.hpp index 8c24780439f99..c4e65e467cb80 100644 --- a/src/common/shared_cache.hpp +++ b/src/common/shared_cache.hpp @@ -128,17 +128,14 @@ public: //clear all strong reference from the lru. void clear() { - VPtr val; // release any ref we have after we drop the lock - while (size > 0) { + while (true) { + VPtr val; // release any ref we have after we drop the lock Mutex::Locker l(lock); - if (size == 0) //check size again with lock + if (size == 0) break; - K key = lru.back().first; - if (weak_refs.count(key)) { - val = weak_refs[key].first.lock(); - } - lru_remove(key); + val = lru.back().second; + lru_remove(lru.back().first); } } -- 2.39.5