]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/instrusive_lru: Implement for_each
authorMatan Breizman <mbreizma@redhat.com>
Tue, 7 Feb 2023 19:47:55 +0000 (19:47 +0000)
committerMatan Breizman <mbreizma@redhat.com>
Sun, 21 May 2023 08:12:29 +0000 (08:12 +0000)
Signed-off-by: Matan Breizman <mbreizma@redhat.com>
(cherry picked from commit 9f8e2329882a2d5101489b7c2445285a43d4ed13)

src/common/intrusive_lru.h
src/crimson/osd/object_context.h

index d780b22119244159da9aa3fab03a7d93870f54a1..e8c3cda3e64e7d5c65098d751ffcfc173c9c6b90 100644 (file)
@@ -167,6 +167,14 @@ public:
       }
   }
 
+  template <class F>
+  void for_each(F&& f) {
+    for (auto& v : lru_set) {
+      access(v);
+      f(TRef{static_cast<T*>(&v)});
+    }
+  }
+
   /**
    * Returns the TRef corresponding to k if it exists or
    * nullptr otherwise.
index a4ecc6ec329e699b5f266a7f33a072fd96801279..48b28ae665f3fed2dcaee3229f110c1c9d919eb3 100644 (file)
@@ -268,6 +268,11 @@ public:
     obc_lru.clear_range(from, to);
   }
 
+  template <class F>
+  void for_each(F&& f) {
+    obc_lru.for_each(std::forward<F>(f));
+  }
+
   const char** get_tracked_conf_keys() const final;
   void handle_conf_change(const crimson::common::ConfigProxy& conf,
                           const std::set <std::string> &changed) final;