From bc282425088455198a7a99511c75914477d4ed32 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 13 Apr 2024 23:14:51 +0200 Subject: Merging upstream version 1.9.3. Signed-off-by: Daniel Baumann --- cachecleaner.hh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'cachecleaner.hh') diff --git a/cachecleaner.hh b/cachecleaner.hh index 9ec8e13..aaf7981 100644 --- a/cachecleaner.hh +++ b/cachecleaner.hh @@ -130,10 +130,9 @@ uint64_t pruneLockedCollectionsVector(std::vector& maps) return totErased; } -template -uint64_t pruneMutexCollectionsVector(C& container, std::vector& maps, uint64_t maxCached, uint64_t cacheSize) +template +uint64_t pruneMutexCollectionsVector(time_t now, std::vector& maps, uint64_t maxCached, uint64_t cacheSize) { - const time_t now = time(nullptr); uint64_t totErased = 0; uint64_t toTrim = 0; uint64_t lookAt = 0; @@ -164,10 +163,10 @@ uint64_t pruneMutexCollectionsVector(C& container, std::vector& maps, uint64_ uint64_t lookedAt = 0; for (auto i = sidx.begin(); i != sidx.end(); lookedAt++) { if (i->isStale(now)) { - container.preRemoval(*shard, *i); + shard->preRemoval(*i); i = sidx.erase(i); erased++; - --content.d_entriesCount; + content.decEntriesCount(); } else { ++i; @@ -224,9 +223,9 @@ uint64_t pruneMutexCollectionsVector(C& container, std::vector& maps, uint64_ auto& sidx = boost::multi_index::get(shard->d_map); size_t removed = 0; for (auto i = sidx.begin(); i != sidx.end() && removed < toTrimForThisShard; removed++) { - container.preRemoval(*shard, *i); + shard->preRemoval(*i); i = sidx.erase(i); - --content.d_entriesCount; + content.decEntriesCount(); ++totErased; if (--toTrim == 0) { return totErased; -- cgit v1.2.3