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
9
11
17
18namespace Tests::Utils {
19
20template <stdexec::sender Sndr, typename Tag, stdexec::scheduler Schd>
22
23template <typename Tag, stdexec::scheduler Schd>
25 [[nodiscard]]
26 constexpr auto operator()() const noexcept {
27 return stdexec::__closure(*this);
28 }
29
30 template <stdexec::sender Sndr>
31 [[nodiscard]]
32 constexpr auto operator()(Sndr&& sndr) const {
33 return CheckSchedulerTypeSender<Sndr, Tag, Schd>{std::forward<Sndr>(sndr)};
34 }
35};
36
37template <stdexec::sender Sndr, typename Tag, stdexec::scheduler Schd>
39 using sender_concept = stdexec::sender_t;
40
41 Sndr sndr; // NOLINT(cppcoreguidelines-avoid-const-or-ref-data-members)
42
44
45 template <stdexec::receiver Rcvr>
46 constexpr auto connect(Rcvr rcvr) && noexcept(stdexec::__nothrow_connectable<Sndr&&, Rcvr&&>) {
47 static_assert(check_scheduler_type<Rcvr>());
48 return stdexec::connect(std::forward<Sndr>(sndr), std::move(rcvr));
49 }
50
51 template <stdexec::receiver Rcvr>
52 constexpr auto connect(Rcvr rcvr) const & noexcept(stdexec::__nothrow_connectable<const Sndr&, Rcvr&&>) {
53 static_assert(check_scheduler_type<Rcvr>());
54 return stdexec::connect(sndr, std::move(rcvr));
55 }
56
57 template <stdexec::receiver Rcvr>
58 static consteval bool check_scheduler_type() {
61 using schd_t = stdexec::__completion_scheduler_of_t<Tag, Sndr, stdexec::env_of_t<Rcvr>>;
62 static_assert(
63 std::same_as<std::remove_cvref_t<schd_t>, Schd>,
64 "Scheduler type mismatch: completion scheduler doesn't match expected type.");
65 return true;
66 }
68 else if constexpr (stdexec::__queryable_with<stdexec::env_of_t<Rcvr>, stdexec::get_scheduler_t>) {
69 using schd_t = stdexec::__query_result_t<stdexec::env_of_t<Rcvr>, stdexec::get_scheduler_t>;
70 static_assert(
71 std::same_as<std::remove_cvref_t<schd_t>, Schd>,
72 "Scheduler type mismatch: receiver scheduler doesn't match expected type.");
73 return true;
74 } else {
75 static_assert(sizeof(Rcvr) == 0, "No scheduler found.");
76 return false;
77 }
78 }
79
81};
82
83template <typename Tag, stdexec::scheduler Schd>
85
86} // namespace Tests::Utils
87
88#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_)
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