mirror of
https://github.com/scylladb/scylladb.git
synced 2026-06-01 20:46:56 +00:00
sstables: sstable_directory: add type constraints
add type constraits for `sstable_directory::parallel_for_each_restricted()`, to enforce the constraints on the function so it should be invocable with the argument of specified type. this helps to prevent the problems of passing function which accepts `pair<key, value>` or `tuple<key, value>`. Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#include <type_traits>
|
||||
#include <seastar/core/coroutine.hh>
|
||||
#include <seastar/coroutine/parallel_for_each.hh>
|
||||
#include <seastar/util/file.hh>
|
||||
@@ -361,6 +362,7 @@ sstable_directory::do_for_each_sstable(std::function<future<>(sstables::shared_s
|
||||
}
|
||||
|
||||
template <typename Container, typename Func>
|
||||
requires std::is_invocable_r_v<future<>, Func, typename std::decay_t<Container>::value_type&>
|
||||
future<>
|
||||
sstable_directory::parallel_for_each_restricted(Container&& C, Func&& func) {
|
||||
return do_with(std::move(C), std::move(func), [this] (Container& c, Func& func) mutable {
|
||||
|
||||
@@ -133,6 +133,7 @@ private:
|
||||
void validate(sstables::shared_sstable sst, process_flags flags) const;
|
||||
|
||||
template <typename Container, typename Func>
|
||||
requires std::is_invocable_r_v<future<>, Func, typename std::decay_t<Container>::value_type&>
|
||||
future<> parallel_for_each_restricted(Container&& C, Func&& func);
|
||||
future<> load_foreign_sstables(sstable_info_vector info_vec);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user