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:
Kefu Chai
2023-03-11 17:22:57 +08:00
parent 0a29d62f4f
commit 97e411bc96
2 changed files with 3 additions and 0 deletions

View File

@@ -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 {

View File

@@ -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);