@@ -24,46 +24,40 @@ template <::beman::execution::scope_token Token, ::beman::execution::sender Send
2424struct associate_data {
2525 using wrap_sender = ::std::remove_cvref_t <decltype (::std::declval<Token&>().wrap(::std::declval<Sender>()))>;
2626
27- explicit associate_data (Token t, Sender&& s)
28- : token(t)
29- , sender(this ->token.wrap(::std::forward<Sender>(s)))
30- {
27+ explicit associate_data (Token t, Sender&& s) : token(t), sender(this ->token.wrap(::std::forward<Sender>(s))) {
3128 if (!token.try_associate ()) {
3229 this ->sender .reset ();
3330 }
3431 }
35- associate_data (associate_data const & other)
36- noexcept (::std::is_nothrow_copy_constructible_v<wrap_sender> && noexcept (token.try_associate()))
37- : token(other.token)
38- , sender()
39- {
32+ associate_data (const associate_data& other) noexcept (::std::is_nothrow_copy_constructible_v<wrap_sender> &&
33+ noexcept (token.try_associate()))
34+ : token(other.token), sender() {
4035 if (other.sender && this ->token .try_associate ()) {
41- try { this ->sender .emplace (*other.sender ); }
42- catch (...) { this ->token .disassociate (); }
36+ try {
37+ this ->sender .emplace (*other.sender );
38+ } catch (...) {
39+ this ->token .disassociate ();
40+ }
4341 }
4442 }
4543 associate_data (associate_data&& other) noexcept (::std::is_nothrow_move_constructible_v<wrap_sender>)
46- : token(other.token)
47- , sender(::std::move(other.sender))
48- {
44+ : token(other.token), sender(::std::move(other.sender)) {
4945 other.sender .reset ();
5046 }
51- auto operator = (associate_data const &) -> associate_data& = delete ;
52- auto operator = (associate_data &&) -> associate_data& = delete ;
47+ auto operator =( const associate_data &) -> associate_data& = delete ;
48+ auto operator =(associate_data&&) -> associate_data& = delete ;
5349 ~associate_data () {
5450 if (this ->sender ) {
5551 this ->sender .reset ();
56- this ->token .disassociate ();
52+ this ->token .disassociate ();
5753 }
5854 }
5955
6056 auto release () -> ::std::optional<::std::pair<Token, wrap_sender>> {
61- return this ->sender
62- ? ( std::unique_ptr<std::optional<wrap_sender>, decltype ([](auto * opt){ opt->reset (); })>(&this ->sender ),
63- ::std::optional{::std::pair{::std::move (this ->token ), ::std::move (*this ->sender )}}
64- )
65- : ::std::optional<::std::pair<Token, wrap_sender>>{}
66- ;
57+ return this ->sender ? (std::unique_ptr<std::optional<wrap_sender>, decltype ([](auto * opt) { opt->reset (); })>(
58+ &this ->sender ),
59+ ::std::optional{::std::pair{::std::move (this ->token ), ::std::move (*this ->sender )}})
60+ : ::std::optional<::std::pair<Token, wrap_sender>>{};
6761 }
6862
6963 Token token;
@@ -80,93 +74,82 @@ struct associate_t {
8074 domain,
8175 ::beman::execution::detail::make_sender (
8276 *this ,
83- ::beman::execution::detail::associate_data (::std::forward<Token>(token), ::std::forward<Sender>(sender))
84- )
85- );
77+ ::beman::execution::detail::associate_data (::std::forward<Token>(token),
78+ ::std::forward<Sender>(sender))));
8679 }
8780};
8881
8982template <>
90- struct impls_for <associate_t >
91- : ::beman::execution::detail::default_impls {
83+ struct impls_for <associate_t > : ::beman::execution::detail::default_impls {
9284 template <typename , typename >
93- struct get_noexcept : ::std::false_type {};
85+ struct get_noexcept : ::std::false_type {};
9486 template <typename Tag, typename Data, typename Receiver>
9587 struct get_noexcept <::beman::execution::detail::basic_sender<Tag, Data>, Receiver>
96- : ::std::bool_constant<
97- ::std::is_nothrow_move_constructible_v<typename ::std::remove_cvref_t <Data>::wrap_sender>
98- && ::beman::execution::detail::nothrow_callable<
99- ::beman::execution::connect_t , typename ::std::remove_cvref_t <Data>::wrap_sender, Receiver>
100- > {};
101-
102- static constexpr auto get_state = []<typename Sender, typename Receiver>(Sender&& sender, Receiver& receiver)
103- noexcept (
104- ::std::is_nothrow_constructible_v<::std::remove_cvref_t <Sender>, Sender>
105- && get_noexcept<::std::remove_cvref_t <Sender>, Receiver>::value
106- )
107- {
108- auto [_, data] = ::std::forward<Sender>(sender);
109- auto dataParts{data.release ()};
110-
111- using scope_token = decltype (dataParts->first );
112- using wrap_sender = decltype (dataParts->second );
113- using op_t = decltype (::beman::execution::connect (::std::move (dataParts->second ), ::std::forward<Receiver>(receiver)));
114-
115- struct op_state {
116- bool associated{false };
117- union {
118- Receiver* rcvr;
119- struct {
120- scope_token tok;
121- op_t op;
122- } assoc;
123- };
124- explicit op_state (Receiver& r) noexcept : rcvr(::std::addressof(r)) {}
125- explicit op_state (scope_token tk, wrap_sender&& sndr, Receiver& r)
126- try
127- : associated(true )
128- , assoc(tk, ::beman::execution::connect(::std::move(sndr), ::std::move(r))) {
129- }
130- catch (...) {
88+ : ::std::bool_constant<
89+ ::std::is_nothrow_move_constructible_v<typename ::std::remove_cvref_t <Data>::wrap_sender>&& ::beman::
90+ execution::detail::nothrow_callable<::beman::execution::connect_t ,
91+ typename ::std::remove_cvref_t <Data>::wrap_sender,
92+ Receiver>> {};
93+
94+ static constexpr auto get_state =
95+ []<typename Sender, typename Receiver>(Sender&& sender, Receiver& receiver) noexcept (
96+ ::std::is_nothrow_constructible_v<::std::remove_cvref_t <Sender>, Sender>&&
97+ get_noexcept<::std::remove_cvref_t <Sender>, Receiver>::value) {
98+ auto [_, data] = ::std::forward<Sender>(sender);
99+ auto dataParts{data.release ()};
100+
101+ using scope_token = decltype (dataParts->first );
102+ using wrap_sender = decltype (dataParts->second );
103+ using op_t = decltype (::beman::execution::connect (::std::move (dataParts->second ),
104+ ::std::forward<Receiver>(receiver)));
105+
106+ struct op_state {
107+ using sop_t = op_t ;
108+ using sscope_token = scope_token;
109+ bool associated{false };
110+ union {
111+ Receiver* rcvr;
112+ struct {
113+ sscope_token tok;
114+ sop_t op;
115+ } assoc;
116+ };
117+ explicit op_state (Receiver& r) noexcept : rcvr(::std::addressof(r)) {}
118+ explicit op_state (sscope_token tk, wrap_sender&& sndr, Receiver& r) try
119+ : associated(true ), assoc(tk, ::beman::execution::connect(::std::move(sndr), ::std::move(r))) {
120+ } catch (...) {
131121 tk.disassociate ();
132122 throw ;
133123 }
134- op_state (op_state&&) = delete ;
135- ~op_state () {
136- if (this ->associated ) {
137- this ->assoc .op .~op_t ();
138- this ->assoc .tok .disassociate ();
139- this ->assoc .tok .~scope_token ();
140- }
141- }
142- auto run () noexcept -> void {
143- if (this ->associated ) {
144- ::beman::execution::start (this ->assoc.op);
124+ op_state (op_state&&) = delete ;
125+ ~op_state () {
126+ if (this ->associated ) {
127+ this ->assoc .op .~sop_t ();
128+ this ->assoc .tok .disassociate ();
129+ this ->assoc .tok .~sscope_token ();
130+ }
145131 }
146- else {
147- ::beman::execution::set_stopped (::std::move(*this ->rcvr));
132+ auto run () noexcept -> void {
133+ if (this ->associated ) {
134+ ::beman::execution::start (this ->assoc.op);
135+ } else {
136+ ::beman::execution::set_stopped (::std::move(*this ->rcvr));
137+ }
148138 }
149- }
139+ };
140+ return dataParts ? op_state (::std::move (dataParts->first ), ::std::move (dataParts->second ), receiver)
141+ : op_state (receiver);
150142 };
151- return dataParts
152- ? op_state (::std::move (dataParts->first ), ::std::move (dataParts->second ), receiver)
153- : op_state (receiver)
154- ;
155- };
156- static constexpr auto start = [](auto & state, auto &&) noexcept -> void {
157- state.run ();
158- };
143+ static constexpr auto start = [](auto & state, auto &&) noexcept -> void { state.run (); };
159144};
160145
161146template <typename Data, typename Env>
162147struct completion_signatures_for_impl <
163148 ::beman::execution::detail::basic_sender<::beman::execution::detail::associate_t , Data>,
164149 Env> {
165- using type = ::beman::execution::completion_signatures<
166- ::beman::execution::set_value_t ()
167- >;
150+ using type = ::beman::execution::completion_signatures<::beman::execution::set_value_t ()>;
168151};
169- }
152+ } // namespace beman::execution::detail
170153
171154namespace beman ::execution {
172155using associate_t = ::beman::execution::detail::associate_t ;
0 commit comments