4
4
#include < async/concepts.hpp>
5
5
#include < async/connect.hpp>
6
6
#include < async/debug_context.hpp>
7
+ #include < async/incite_on.hpp>
8
+ #include < async/just.hpp>
7
9
#include < async/schedulers/trigger_scheduler.hpp>
8
10
#include < async/start.hpp>
9
11
#include < async/then.hpp>
17
19
18
20
namespace msg {
19
21
namespace _send_recv {
20
- template <typename Sched>
21
- using scheduler_sender = decltype (std::declval<Sched>().schedule());
22
-
23
22
template <typename S>
24
23
concept valid_send_action =
25
24
requires { typename std::remove_cvref_t <S>::is_send_action; };
26
25
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;
79
28
using is_send_action = void ;
80
29
};
81
30
template <typename F> send_action (F) -> send_action<F>;
@@ -88,9 +37,8 @@ template <stdx::ct_string Name, typename... Args> struct pipeable {
88
37
template <valid_send_action S, stdx::same_as_unqualified<type> Self>
89
38
friend constexpr auto operator |(S &&s, Self &&self) -> async::sender
90
39
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...>{}) |
94
42
std::forward<Self>(self).a ;
95
43
}
96
44
};
@@ -102,8 +50,8 @@ template <stdx::ct_string Name, typename... Args> struct pipeable {
102
50
template <typename F, typename ... Args>
103
51
constexpr auto send (F &&f, Args &&...args) {
104
52
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) ...);
107
55
}};
108
56
}
109
57
@@ -122,14 +70,4 @@ template <stdx::ct_string Name, _send_recv::valid_send_action S, typename F,
122
70
return std::forward<S>(s) |
123
71
then_receive<Name>(std::forward<F>(f), std::forward<Args>(args)...);
124
72
}
125
-
126
- struct send_t ;
127
73
} // 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