1
0
Mirror von https://github.com/tkuschel/bees.git synchronisiert 2026-05-07 20:49:38 +02:00

cache: add a method to get estimated cache size

Estimated because there is no lock preventing the result from
changing before it is used.

Signed-off-by: Zygo Blaxell <bees@furryterror.org>
Dieser Commit ist enthalten in:
Zygo Blaxell
2021-12-05 20:27:18 -05:00
Ursprung 331cb142e3
Commit ece58cc910
+10 -1
Datei anzeigen
@@ -30,7 +30,7 @@ namespace crucible {
map<Key, ListIter> m_map;
LockSet<Key> m_lockset;
size_t m_max_size;
mutex m_mutex;
mutable mutex m_mutex;
void check_overflow();
void recent_use(ListIter vp);
@@ -48,6 +48,7 @@ namespace crucible {
void expire(Arguments... args);
void insert(const Return &r, Arguments... args);
void clear();
size_t size() const;
};
template <class Return, class... Arguments>
@@ -190,6 +191,14 @@ namespace crucible {
lock.unlock();
}
template <class Return, class... Arguments>
size_t
LRUCache<Return, Arguments...>::size() const
{
unique_lock<mutex> lock(m_mutex);
return m_map.size();
}
template<class Return, class... Arguments>
Return
LRUCache<Return, Arguments...>::operator()(Arguments... args)