kokkos-execution 0.0.1
Loading...
Searching...
No Matches
stopped.hpp
Go to the documentation of this file.
1#ifndef KOKKOS_EXECUTION_TESTS_UTILS_SCHEDULERS_STOPPED_HPP
2#define KOKKOS_EXECUTION_TESTS_UTILS_SCHEDULERS_STOPPED_HPP
3
5
8
10
22struct Stopped {
23 public:
24 using scheduler_concept = stdexec::scheduler_tag;
25
26 private:
27 struct Sender;
28
29 public:
30 [[nodiscard]]
31 constexpr auto schedule() const noexcept -> Sender {
32 return {};
33 }
34
35 template <stdexec::__one_of<stdexec::set_value_t, stdexec::set_stopped_t> Tag>
36 [[nodiscard]]
37 constexpr auto query(stdexec::get_completion_scheduler_t<Tag>) const noexcept -> Stopped {
38 return {};
39 }
40
41 [[nodiscard]]
42 friend bool operator==(const Stopped&, const Stopped&) noexcept = default;
43
44 private:
45 template <stdexec::receiver Rcvr>
47 void start() & noexcept {
48 stdexec::set_stopped(std::move(rcvr));
49 }
50
51 Rcvr rcvr;
52 };
53
54 struct Sender {
55 using sender_concept = stdexec::sender_tag;
56
57 using completion_signatures = stdexec::completion_signatures<stdexec::set_value_t(), stdexec::set_stopped_t()>;
58
59 template <stdexec::receiver_of<completion_signatures> Rcvr>
60 constexpr auto connect(Rcvr rcvr) && KOKKOS_EXECUTION_RETURNS_BRACED(OpState<Rcvr>, {}, std::move(rcvr))
61
62 [[nodiscard]]
64 return {};
65 }
66 };
67};
68
69} // namespace Tests::Utils::Schedulers
70
71#endif // KOKKOS_EXECUTION_TESTS_UTILS_SCHEDULERS_STOPPED_HPP
#define KOKKOS_EXECUTION_RETURNS_BRACED(_type_,...)
Define a function by returning a list-initialized object of an explicit type.
Definition macros.hpp:23
Inspired by https://github.com/NVIDIA/stdexec/blob/2184dd714f82df1e00d39961817be97f31c02744/test/test...
constexpr auto get_env() const noexcept -> Attributes< Stopped, stdexec::set_value_t, stdexec::set_stopped_t >
Definition stopped.hpp:63
stdexec::completion_signatures< stdexec::set_value_t(), stdexec::set_stopped_t()> completion_signatures
Definition stopped.hpp:57
constexpr auto connect(Rcvr rcvr) &&noexcept(noexcept(OpState< Rcvr >{{}, std::move(rcvr)})) -> OpState< Rcvr >
Definition stopped.hpp:60
Scheduler that returns a sender that always completes on the stop channel.
Definition stopped.hpp:22
stdexec::scheduler_tag scheduler_concept
Definition stopped.hpp:24
friend bool operator==(const Stopped &, const Stopped &) noexcept=default
constexpr auto schedule() const noexcept -> Sender
Definition stopped.hpp:31
constexpr auto query(stdexec::get_completion_scheduler_t< Tag >) const noexcept -> Stopped
Definition stopped.hpp:37