diff options
author | Samuel Just <sjust@redhat.com> | 2024-01-18 05:22:10 +0100 |
---|---|---|
committer | Samuel Just <sjust@redhat.com> | 2024-01-18 06:08:17 +0100 |
commit | 10c9fb3240f987b605de6fe7c3c1e66bb32d89aa (patch) | |
tree | 2a0a461c9641a36775e02bfccb504be91307c674 /src/common/intrusive_lru.h | |
parent | common/intrusive_lru: clarify invariants (diff) | |
download | ceph-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.h | 10 |
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() { |