From 50b02ee0bd714cb02678fc1738fd4d6bfd2f91cd Mon Sep 17 00:00:00 2001 From: "Raphael S. Carvalho" Date: Fri, 25 Nov 2022 21:30:52 -0300 Subject: [PATCH] replica: Introduce table::parallel_foreach_table_state() This will replace table::as_table_state(). The latter will be killed once its usage drops to zero. Signed-off-by: Raphael S. Carvalho --- replica/database.hh | 3 +++ replica/table.cc | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/replica/database.hh b/replica/database.hh index 91a26eb746..ec9eba8fd4 100644 --- a/replica/database.hh +++ b/replica/database.hh @@ -1110,7 +1110,10 @@ public: void update_off_strategy_trigger(); void enable_off_strategy_trigger(); + // FIXME: get rid of it once no users. compaction::table_state& as_table_state() const noexcept; + // Safely iterate through table states, while performing async operations on them. + future<> parallel_foreach_table_state(std::function(compaction::table_state&)> action); friend class compaction_group; }; diff --git a/replica/table.cc b/replica/table.cc index 0e934b70e2..f9aefe8334 100644 --- a/replica/table.cc +++ b/replica/table.cc @@ -2674,6 +2674,12 @@ compaction::table_state& table::as_table_state() const noexcept { return _compaction_group->as_table_state(); } +future<> table::parallel_foreach_table_state(std::function(table_state&)> action) { + return parallel_foreach_compaction_group([action = std::move(action)] (compaction_group& cg) -> future<> { + return action(cg.as_table_state()); + }); +} + data_dictionary::table table::as_data_dictionary() const { static constinit data_dictionary_impl _impl;