kokkos-execution 0.0.1
Loading...
Searching...
No Matches
continues_on.hpp
Go to the documentation of this file.
1#ifndef KOKKOS_EXECUTION_EXECUTION_SPACE_CONTINUES_ON_HPP
2#define KOKKOS_EXECUTION_EXECUTION_SPACE_CONTINUES_ON_HPP
3
5PRAGMA_DIAGNOSTIC_PUSH
7#include "exec/env.hpp"
8PRAGMA_DIAGNOSTIC_POP
9
16
18
19struct FwdWithExec { };
20struct FwdWithoutExec { };
21
23template <stdexec::receiver Rcvr, typename FwdPolicy = FwdWithExec>
25 using receiver_concept = stdexec::receiver_t;
26
27 Rcvr rcvr;
28
29 void set_value() && noexcept {
30 stdexec::set_value(std::move(rcvr));
31 }
32
33 template <typename Error>
34 void set_error(Error&& err) && noexcept {
35 stdexec::set_error(std::move(rcvr), std::forward<Error>(err));
36 }
37
38 void set_stopped() && noexcept {
39 stdexec::set_stopped(std::move(rcvr));
40 }
41
42 [[nodiscard]]
43 constexpr auto get_env() const noexcept -> std::conditional_t<
44 std::same_as<FwdPolicy, FwdWithoutExec>,
45 stdexec::__call_result_t<
46 experimental::execution::__envs::__without_t,
47 stdexec::__fwd_env_t<stdexec::env_of_t<Rcvr>>,
49 >,
50 stdexec::__fwd_env_t<stdexec::env_of_t<Rcvr>>
51 > {
52 if constexpr (std::same_as<FwdPolicy, FwdWithoutExec>) {
53 return experimental::execution::without(stdexec::__fwd_env(stdexec::get_env(rcvr)), get_exec);
54 } else {
55 return stdexec::__fwd_env(stdexec::get_env(rcvr));
56 }
57 }
58};
59
61template <stdexec::sender Sndr>
63 using sender_concept = stdexec::sender_t;
64
65 Sndr sndr; // NOLINT(cppcoreguidelines-avoid-const-or-ref-data-members)
66
68
69 template <
70 stdexec::receiver Rcvr,
71 typename FwdPolicy = std::conditional_t<
72 std::same_as<
73 stdexec::__detail::__completing_domain_t<stdexec::set_value_t, Sndr, stdexec::env_of_t<Rcvr>>,
74 Domain
75 >
77 stdexec::set_value_t,
78 Domain,
79 Sndr,
80 stdexec::env_of_t<Rcvr>
81 >
83 stdexec::set_value_t,
84 Domain,
85 Sndr,
86 stdexec::env_of_t<Rcvr>
87 >,
90 >
91 >
92 auto connect(Rcvr rcvr) && noexcept(std::is_nothrow_move_constructible_v<Rcvr>)
93 -> stdexec::connect_result_t<Sndr, ContinuesOnReceiver<Rcvr, FwdPolicy>> {
95
96 return stdexec::connect(std::forward<Sndr>(sndr), recv_t{.rcvr = std::move(rcvr)});
97 }
98
100};
101
102template <>
103struct TransformSenderFor<stdexec::continues_on_t> {
104 template <typename Env, stdexec::__is_instance_of<Scheduler> Schd, stdexec::sender Sndr>
105 auto operator()(const Env&, stdexec::continues_on_t, Schd&&, Sndr&& sndr) const
106 noexcept(std::is_nothrow_constructible_v<ContinuesOnSender<Sndr>, Sndr&&>) {
107 return ContinuesOnSender<Sndr>{.sndr = std::forward<Sndr>(sndr)};
108 }
109};
110
111} // namespace Kokkos::Execution::ExecutionSpaceImpl
112
113#endif // KOKKOS_EXECUTION_EXECUTION_SPACE_CONTINUES_ON_HPP
#define KOKKOS_EXECUTION_IMPL_FORWARDING_ATTRIBUTES_GET_ENV(_type_, _obj_)
#define KOKKOS_EXECUTION_COMPL_SIGS_KEEP(_sndr_type_)
#define KOKKOS_EXECUTION_STDEXEC_PRAGMA_DIAGNOSTIC_IGNORED
Basic list of ignored diagnostics when including anything from stdexec.
constexpr bool has_when_all_child_with_at_least_one_child_completing_on_v
constexpr bool has_fork_join_child_with_at_least_one_child_completing_on_v
constexpr auto get_env() const noexcept -> std::conditional_t< std::same_as< FwdPolicy, FwdWithoutExec >, stdexec::__call_result_t< experimental::execution::__envs::__without_t, stdexec::__fwd_env_t< stdexec::env_of_t< Rcvr > >, get_exec_t >, stdexec::__fwd_env_t< stdexec::env_of_t< Rcvr > > >
auto connect(Rcvr rcvr) &&noexcept(std::is_nothrow_move_constructible_v< Rcvr >) -> stdexec::connect_result_t< Sndr, ContinuesOnReceiver< Rcvr, FwdPolicy > >
auto operator()(const Env &, stdexec::continues_on_t, Schd &&, Sndr &&sndr) const noexcept(std::is_nothrow_constructible_v< ContinuesOnSender< Sndr >, Sndr && >)