From e914da51a10ac4263a186980fb38da35a3916ef0 Mon Sep 17 00:00:00 2001 From: Matan Breizman Date: Tue, 7 Feb 2023 19:47:55 +0000 Subject: [PATCH] common/instrusive_lru: Implement for_each Signed-off-by: Matan Breizman (cherry picked from commit 9f8e2329882a2d5101489b7c2445285a43d4ed13) --- src/common/intrusive_lru.h | 8 ++++++++ src/crimson/osd/object_context.h | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/src/common/intrusive_lru.h b/src/common/intrusive_lru.h index d780b22119244..e8c3cda3e64e7 100644 --- a/src/common/intrusive_lru.h +++ b/src/common/intrusive_lru.h @@ -167,6 +167,14 @@ public: } } + template + void for_each(F&& f) { + for (auto& v : lru_set) { + access(v); + f(TRef{static_cast(&v)}); + } + } + /** * Returns the TRef corresponding to k if it exists or * nullptr otherwise. diff --git a/src/crimson/osd/object_context.h b/src/crimson/osd/object_context.h index a4ecc6ec329e6..48b28ae665f3f 100644 --- a/src/crimson/osd/object_context.h +++ b/src/crimson/osd/object_context.h @@ -268,6 +268,11 @@ public: obc_lru.clear_range(from, to); } + template + void for_each(F&& f) { + obc_lru.for_each(std::forward(f)); + } + const char** get_tracked_conf_keys() const final; void handle_conf_change(const crimson::common::ConfigProxy& conf, const std::set &changed) final; -- 2.39.5