44#include < async/concepts.hpp>
55#include < async/connect.hpp>
66#include < async/debug_context.hpp>
7+ #include < async/incite_on.hpp>
8+ #include < async/just.hpp>
79#include < async/schedulers/trigger_scheduler.hpp>
810#include < async/start.hpp>
911#include < async/then.hpp>
1719
1820namespace msg {
1921namespace _send_recv {
20- template <typename Sched>
21- using scheduler_sender = decltype (std::declval<Sched>().schedule());
22-
2322template <typename S>
2423concept valid_send_action =
2524 requires { typename std::remove_cvref_t <S>::is_send_action; };
2625
27- template <valid_send_action SA, typename Sched, typename Rcvr>
28- // NOLINTNEXTLINE(cppcoreguidelines-special-member-functions)
29- struct op_state {
30- template <stdx::same_as_unqualified<SA> S, typename Sch, typename R>
31- constexpr op_state (S &&s, Sch &&sch, R &&r)
32- : send(s), ops{async::connect (std::forward<Sch>(sch).schedule (),
33- std::forward<R>(r))} {}
34- constexpr op_state (op_state &&) = delete;
35-
36- using ops_t = async::connect_result_t <scheduler_sender<Sched>, Rcvr>;
37-
38- constexpr auto start () & -> void {
39- async::start (ops);
40- send ();
41- }
42-
43- SA send;
44- ops_t ops;
45- };
46-
47- template <valid_send_action SA, typename Sched> struct sender {
48- using is_sender = void ;
49-
50- [[no_unique_address]] SA send;
51- [[no_unique_address]] Sched sched;
52-
53- public:
54- template <async::receiver R>
55- [[nodiscard]] constexpr auto
56- connect (R &&r) && -> op_state<SA, Sched, std::remove_cvref_t <R>> {
57- async::check_connect<sender &&, R>();
58- return {std::move (send), std::move (sched), std::forward<R>(r)};
59- }
60-
61- template <async::receiver R>
62- [[nodiscard]] constexpr auto
63- connect (R &&r) const & -> op_state<SA, Sched, std::remove_cvref_t <R>> {
64- async::check_connect<sender, R>();
65- return {send, sched, std::forward<R>(r)};
66- }
67-
68- template <typename Env>
69- [[nodiscard]] constexpr static auto get_completion_signatures (Env const &)
70- -> async::completion_signatures_of_t<scheduler_sender<Sched>, Env> {
71- return {};
72- }
73- };
74-
75- template <typename Sndr, typename Sched>
76- sender (Sndr, Sched) -> sender<Sndr, Sched>;
77-
78- template <typename F> struct send_action : F {
26+ template <typename F> struct send_action {
27+ [[no_unique_address]] F f;
7928 using is_send_action = void ;
8029};
8130template <typename F> send_action (F) -> send_action<F>;
@@ -88,9 +37,8 @@ template <stdx::ct_string Name, typename... Args> struct pipeable {
8837 template <valid_send_action S, stdx::same_as_unqualified<type> Self>
8938 friend constexpr auto operator |(S &&s, Self &&self) -> async::sender
9039 auto {
91- return _send_recv::sender{
92- std::forward<S>(s),
93- async::trigger_scheduler<Name, Args...>{}} |
40+ return async::just (std::forward<S>(s).f ) |
41+ async::incite_on (async::trigger_scheduler<Name, Args...>{}) |
9442 std::forward<Self>(self).a ;
9543 }
9644 };
@@ -102,8 +50,8 @@ template <stdx::ct_string Name, typename... Args> struct pipeable {
10250template <typename F, typename ... Args>
10351constexpr auto send (F &&f, Args &&...args) {
10452 return _send_recv::send_action{
105- [f = std::forward<F>(f), ... args = std::forward<Args>(args)]() {
106- return f (args ...);
53+ [f = std::forward<F>(f), ... as = std::forward<Args>(args)] {
54+ return std::move (f)( std::move (as) ...);
10755 }};
10856}
10957
@@ -122,14 +70,4 @@ template <stdx::ct_string Name, _send_recv::valid_send_action S, typename F,
12270 return std::forward<S>(s) |
12371 then_receive<Name>(std::forward<F>(f), std::forward<Args>(args)...);
12472}
125-
126- struct send_t ;
12773} // namespace msg
128-
129- template <typename ... Ts>
130- struct async ::debug::context_for<msg::_send_recv::op_state<Ts...>> {
131- using tag = msg::send_t ;
132- constexpr static auto name = stdx::ct_string{" msg_send" };
133- using type = msg::_send_recv::op_state<Ts...>;
134- using children = stdx::type_list<>;
135- };
0 commit comments