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 <raphaelsc@scylladb.com>
This commit is contained in:
Raphael S. Carvalho
2022-11-25 21:30:52 -03:00
parent fd69bd433e
commit 50b02ee0bd
2 changed files with 9 additions and 0 deletions

View File

@@ -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<future<>(compaction::table_state&)> action);
friend class compaction_group;
};

View File

@@ -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<future<>(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;