kokkos-execution 0.0.1
Loading...
Searching...
No Matches
check_scheduler_type.hpp
Go to the documentation of this file.
1#ifndef KOKKOS_EXECUTION_TESTS_UTILS_CHECK_SCHEDULER_TYPE_HPP
2#define KOKKOS_EXECUTION_TESTS_UTILS_CHECK_SCHEDULER_TYPE_HPP
3
5
10
12
18
19namespace Tests::Utils {
20
21template <stdexec::sender Sndr, typename Tag, stdexec::scheduler Schd>
23
24template <typename Tag, stdexec::scheduler Schd>
26 [[nodiscard]]
27 constexpr auto operator()() const noexcept {
28 return stdexec::__closure(*this);
29 }
30
31 template <stdexec::sender Sndr>
32 [[nodiscard]]
33 constexpr auto operator()(Sndr&& sndr) const {
34 return CheckSchedulerTypeSender<Sndr, Tag, Schd>{std::forward<Sndr>(sndr)};
35 }
36};
37
38template <stdexec::sender Sndr, typename Tag, stdexec::scheduler Schd>
40 using sender_concept = stdexec::sender_tag;
41
42 Sndr sndr; // NOLINT(cppcoreguidelines-avoid-const-or-ref-data-members)
43
45
46 template <stdexec::receiver Rcvr>
47 constexpr auto connect(Rcvr rcvr) && noexcept(stdexec::__nothrow_connectable<Sndr&&, Rcvr&&>) {
48 static_assert(check_scheduler_type<Rcvr>());
49 return stdexec::connect(std::forward<Sndr>(sndr), std::move(rcvr));
50 }
51
52 template <stdexec::receiver Rcvr>
53 constexpr auto connect(Rcvr rcvr) const & noexcept(stdexec::__nothrow_connectable<const Sndr&, Rcvr&&>) {
54 static_assert(check_scheduler_type<Rcvr>());
55 return stdexec::connect(sndr, std::move(rcvr));
56 }
57
58 template <stdexec::receiver Rcvr>
59 static consteval bool check_scheduler_type() {
63 static_assert(
64 std::same_as<std::remove_cvref_t<schd_t>, Schd>,
65 "Scheduler type mismatch: completion scheduler doesn't match expected type.");
66 return true;
67 }
69 else if constexpr (stdexec::__queryable_with<stdexec::env_of_t<Rcvr>, stdexec::get_scheduler_t>) {
70 using schd_t = stdexec::__query_result_t<stdexec::env_of_t<Rcvr>, stdexec::get_scheduler_t>;
71 static_assert(
72 std::same_as<std::remove_cvref_t<schd_t>, Schd>,
73 "Scheduler type mismatch: receiver scheduler doesn't match expected type.");
74 return true;
75 } else {
76 static_assert(sizeof(Rcvr) == 0, "No scheduler found.");
77 return false;
78 }
79 }
80
82};
83
84template <typename Tag, stdexec::scheduler Schd>
86
87} // namespace Tests::Utils
88
89#endif // KOKKOS_EXECUTION_TESTS_UTILS_CHECK_SCHEDULER_TYPE_HPP
#define KOKKOS_EXECUTION_IMPL_FORWARDING_ATTRIBUTES_GET_ENV(_type_, _obj_)
#define KOKKOS_EXECUTION_COMPL_SIGS_KEEP(_sndr_type_)
std::invoke_result_t< stdexec::get_completion_scheduler_t< Tag >, stdexec::env_of_t< Sndr >, Env... > completion_scheduler_of_t
Retrieve the completion scheduler for a given completion tag.
constexpr check_scheduler_type_t< Tag, Schd > check_scheduler_type
constexpr auto connect(Rcvr rcvr) &&noexcept(stdexec::__nothrow_connectable< Sndr &&, Rcvr && >)
constexpr auto connect(Rcvr rcvr) const &noexcept(stdexec::__nothrow_connectable< const Sndr &, Rcvr && >)
constexpr auto operator()(Sndr &&sndr) const
constexpr auto operator()() const noexcept