summaryrefslogtreecommitdiffstats
path: root/src/common/intrusive_lru.h
diff options
context:
space:
mode:
authorSamuel Just <sjust@redhat.com>2024-01-18 05:22:10 +0100
committerSamuel Just <sjust@redhat.com>2024-01-18 06:08:17 +0100
commit10c9fb3240f987b605de6fe7c3c1e66bb32d89aa (patch)
tree2a0a461c9641a36775e02bfccb504be91307c674 /src/common/intrusive_lru.h
parentcommon/intrusive_lru: clarify invariants (diff)
downloadceph-10c9fb3240f987b605de6fe7c3c1e66bb32d89aa.tar.xz
ceph-10c9fb3240f987b605de6fe7c3c1e66bb32d89aa.zip
common/intrusive_lru: generalize evict() slightly to allow other target values
Signed-off-by: Samuel Just <sjust@redhat.com>
Diffstat (limited to '')
-rw-r--r--src/common/intrusive_lru.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/common/intrusive_lru.h b/src/common/intrusive_lru.h
index 6ae13c8f99f..fb94b5fd9ea 100644
--- a/src/common/intrusive_lru.h
+++ b/src/common/intrusive_lru.h
@@ -122,9 +122,9 @@ class intrusive_lru {
// when the lru_set exceeds its target size, evict
// only unreferenced elements from it (if any).
- void evict() {
+ void evict(unsigned target_size) {
while (!unreferenced_list.empty() &&
- lru_set.size() > lru_target_size) {
+ lru_set.size() > target_size) {
auto &evict_target = unreferenced_list.front();
assert(evict_target.is_unreferenced());
unreferenced_list.pop_front();
@@ -150,7 +150,7 @@ class intrusive_lru {
assert(b.is_unreferenced());
lru_set.insert(b);
b.lru = this;
- evict();
+ evict(lru_target_size);
}
// an element in the lru_set has no users,
@@ -159,7 +159,7 @@ class intrusive_lru {
assert(b.is_referenced());
unreferenced_list.push_back(b);
b.lru = nullptr;
- evict();
+ evict(lru_target_size);
}
public:
@@ -226,7 +226,7 @@ public:
void set_target_size(size_t target_size) {
lru_target_size = target_size;
- evict();
+ evict(lru_target_size);
}
~intrusive_lru() {