@@ -29,105 +29,104 @@ namespace beman::execution::detail {
2929inline constexpr struct stop_when_t {
3030
3131 template <::beman::execution::sender Sndr, ::beman::execution::stoppable_token Tok>
32- struct sender {
33- using sender_concept = ::beman::execution::sender_t ;
34-
35- std::remove_cvref_t <Sndr> sndr;
36- std::remove_cvref_t <Tok> tok;
37-
38- template <::beman::execution::receiver Rcvr>
39- struct state {
40- using operation_state_concept = ::beman::execution::operation_state_t ;
41- using rcvr_t = ::std::remove_cvref_t <Rcvr>;
42- using token1_t = ::std::remove_cvref_t <Tok>;
43- using token2_t =
44- decltype (::beman::execution::get_stop_token(::beman::execution::get_env(::std::declval<rcvr_t >())));
45-
46- struct cb_t {
47- ::beman::execution::inplace_stop_source& source;
48- auto operator ()() const noexcept { this ->source .request_stop (); }
49- };
50- struct base_state {
51- rcvr_t rcvr;
52- ::beman::execution::inplace_stop_source source{};
53- };
54- struct env {
55- base_state* st;
56- auto query (const ::beman::execution::get_stop_token_t &) const noexcept {
57- return this ->st ->source .get_token ();
58- }
59- template <typename Q, typename ... A>
60- requires requires (const Q& q, A&&... a, const rcvr_t & r) {
61- q (::beman::execution::get_env (r), ::std::forward<A>(a)...);
62- }
63- auto query (const Q& q, A&&... a) const noexcept {
64- return q (::beman::execution::get_env (this ->st ->rcvr ), ::std::forward<A>(a)...);
65- }
66- };
67-
68- struct receiver {
69- using receiver_concept = ::beman::execution::receiver_t ;
70- base_state* st;
71-
72- auto get_env () const noexcept -> env { return env{this ->st }; }
73- template <typename ... A>
74- auto set_value (A&&... a) const noexcept -> void {
75- ::beman::execution::set_value (::std::move(this ->st->rcvr), ::std::forward<A>(a)...);
76- }
77- template <typename E>
78- auto set_error (E&& e) const noexcept -> void {
79- ::beman::execution::set_error (::std::move(this ->st->rcvr), ::std::forward<E>(e));
80- }
81- auto set_stopped () const noexcept -> void {
82- ::beman::execution::set_stopped (::std::move(this ->st->rcvr));
83- }
84- };
85- using inner_state_t =
86- decltype (::beman::execution::connect(::std::declval<Sndr>(), ::std::declval<receiver>()));
87-
88- token1_t tok;
89- base_state base;
90- std::optional<::beman::execution::stop_callback_for_t <token1_t , cb_t >> cb1;
91- std::optional<::beman::execution::stop_callback_for_t <token2_t , cb_t >> cb2;
92- inner_state_t inner_state;
93-
94- template <::beman::execution::sender S,
95- ::beman::execution::stoppable_token T,
96- ::beman::execution::receiver R>
97- state (S&& s, T&& t, R&& r)
98- : tok(::std::forward<T>(t)),
99- base{::std::forward<R>(r)},
100- inner_state (::beman::execution::connect(::std::forward<S>(s), receiver(&this ->base))) {}
101-
102- auto start () & noexcept {
103- this ->cb1 .emplace (this ->tok , cb_t (this ->base .source ));
104- this ->cb2 .emplace (::beman::execution::get_stop_token (::beman::execution::get_env (this ->base .rcvr )),
105- cb_t (this ->base .source ));
106- ::beman::execution::start (this ->inner_state);
107- }
108- };
109-
110- template <typename E>
111- auto get_completion_signatures (const E& e) const noexcept {
112- return ::beman::execution::get_completion_signatures (this ->sndr , e);
113- }
114- template <::beman::execution::receiver Rcvr>
115- auto connect (Rcvr&& rcvr) && -> state<Rcvr> {
116- return state<Rcvr>{std::move (this ->sndr ), ::std::move (this ->tok ), ::std::forward<Rcvr>(rcvr)};
117- }
118- };
32+ struct sender ;
11933
12034 template <::beman::execution::sender Sndr, ::beman::execution::stoppable_token Tok>
12135 auto operator ()(Sndr&& sndr, Tok&& tok) const noexcept {
12236 if constexpr (::beman::execution::unstoppable_token<Tok>) {
12337 return ::std::forward<Sndr>(sndr);
12438 } else {
125- return sender<Sndr, Tok>(::std::forward<Sndr>(sndr ), ::std::forward<Tok>(tok ));
39+ return sender<Sndr, Tok>(* this , ::std::forward<Tok>(tok ), ::std::forward<Sndr>(sndr ));
12640 }
12741 }
12842} stop_when{};
12943} // namespace beman::execution::detail
13044
45+ template <::beman::execution::sender Sndr, ::beman::execution::stoppable_token Tok>
46+ struct beman ::execution::detail::stop_when_t ::sender {
47+ using sender_concept = ::beman::execution::sender_t ;
48+
49+ stop_when_t stop_when{};
50+ std::remove_cvref_t <Tok> tok;
51+ std::remove_cvref_t <Sndr> sndr;
52+
53+ template <::beman::execution::receiver Rcvr>
54+ struct state {
55+ using operation_state_concept = ::beman::execution::operation_state_t ;
56+ using rcvr_t = ::std::remove_cvref_t <Rcvr>;
57+ using token1_t = ::std::remove_cvref_t <Tok>;
58+ using token2_t =
59+ decltype (::beman::execution::get_stop_token(::beman::execution::get_env(::std::declval<rcvr_t >())));
60+
61+ struct cb_t {
62+ ::beman::execution::inplace_stop_source& source;
63+ auto operator ()() const noexcept { this ->source .request_stop (); }
64+ };
65+ struct base_state {
66+ rcvr_t rcvr;
67+ ::beman::execution::inplace_stop_source source{};
68+ };
69+ struct env {
70+ base_state* st;
71+ auto query (const ::beman::execution::get_stop_token_t &) const noexcept {
72+ return this ->st ->source .get_token ();
73+ }
74+ template <typename Q, typename ... A>
75+ requires requires (const Q& q, A&&... a, const rcvr_t & r) {
76+ q (::beman::execution::get_env (r), ::std::forward<A>(a)...);
77+ }
78+ auto query (const Q& q, A&&... a) const noexcept {
79+ return q (::beman::execution::get_env (this ->st ->rcvr ), ::std::forward<A>(a)...);
80+ }
81+ };
82+
83+ struct receiver {
84+ using receiver_concept = ::beman::execution::receiver_t ;
85+ base_state* st;
86+
87+ auto get_env () const noexcept -> env { return env{this ->st }; }
88+ template <typename ... A>
89+ auto set_value (A&&... a) const noexcept -> void {
90+ ::beman::execution::set_value (::std::move(this ->st->rcvr), ::std::forward<A>(a)...);
91+ }
92+ template <typename E>
93+ auto set_error (E&& e) const noexcept -> void {
94+ ::beman::execution::set_error (::std::move(this ->st->rcvr), ::std::forward<E>(e));
95+ }
96+ auto set_stopped () const noexcept -> void { ::beman::execution::set_stopped (::std::move (this ->st ->rcvr )); }
97+ };
98+ using inner_state_t =
99+ decltype (::beman::execution::connect(::std::declval<Sndr>(), ::std::declval<receiver>()));
100+
101+ token1_t tok;
102+ base_state base;
103+ std::optional<::beman::execution::stop_callback_for_t <token1_t , cb_t >> cb1;
104+ std::optional<::beman::execution::stop_callback_for_t <token2_t , cb_t >> cb2;
105+ inner_state_t inner_state;
106+
107+ template <::beman::execution::sender S, ::beman::execution::stoppable_token T, ::beman::execution::receiver R>
108+ state (S&& s, T&& t, R&& r)
109+ : tok(::std::forward<T>(t)),
110+ base{::std::forward<R>(r)},
111+ inner_state (::beman::execution::connect(::std::forward<S>(s), receiver(&this ->base))) {}
112+
113+ auto start () & noexcept {
114+ this ->cb1 .emplace (this ->tok , cb_t (this ->base .source ));
115+ this ->cb2 .emplace (::beman::execution::get_stop_token (::beman::execution::get_env (this ->base .rcvr )),
116+ cb_t (this ->base .source ));
117+ ::beman::execution::start (this ->inner_state);
118+ }
119+ };
120+
121+ template <typename E>
122+ auto get_completion_signatures (const E& e) const noexcept {
123+ return ::beman::execution::get_completion_signatures (this ->sndr , e);
124+ }
125+ template <::beman::execution::receiver Rcvr>
126+ auto connect (Rcvr&& rcvr) && -> state<Rcvr> {
127+ return state<Rcvr>{std::move (this ->sndr ), ::std::move (this ->tok ), ::std::forward<Rcvr>(rcvr)};
128+ }
129+ };
131130// ----------------------------------------------------------------------------
132131
133132#endif
0 commit comments