1919#include < beman/execution26/detail/forward_like.hpp>
2020#include < beman/execution26/detail/fwd_env.hpp>
2121#include < beman/execution26/detail/sched_env.hpp>
22+ #include < beman/execution26/detail/starts_on.hpp>
23+ #include < beman/execution26/detail/continues_on.hpp>
24+ #include < beman/execution26/detail/write_env.hpp>
2225#include < utility>
2326
2427// ----------------------------------------------------------------------------
2528
2629namespace beman ::execution26::detail {
27- struct on_t {
30+ struct on_t : ::beman::execution26::sender_adaptor_closure< on_t > {
2831 template <::beman::execution26::detail::sender_for<on_t > OutSndr, typename Env>
2932 auto transform_env (OutSndr&& out_sndr, Env&& env) const -> decltype(auto ) {
30- // auto&&[_, data, _] = out_sndr;
3133 auto && data{out_sndr.template get <1 >()};
3234
3335 if constexpr (::beman::execution26::scheduler<decltype (data)>)
@@ -40,6 +42,56 @@ struct on_t {
4042 return std::forward<Env>(env);
4143 }
4244
45+ template <typename >
46+ struct env_needs_get_scheduler {
47+ using sender_concept = ::beman::execution26::sender_t ;
48+ template <typename Env>
49+ auto get_completion_signatures (Env&&) const {
50+ return env_needs_get_scheduler<Env>{};
51+ }
52+ };
53+
54+ template <::beman::execution26::detail::sender_for<on_t > OutSndr, typename Env>
55+ auto transform_sender (OutSndr&& out_sndr, Env&& env) const -> decltype(auto ) {
56+ struct not_a_scheduler {};
57+ auto && [_, data, child] = out_sndr;
58+
59+ if constexpr (::beman::execution26::scheduler<decltype (data)>) {
60+ auto sch{::beman::execution26::detail::query_with_default (
61+ ::beman::execution26::get_scheduler, env, not_a_scheduler{})};
62+ if constexpr (::std::same_as<not_a_scheduler, decltype (sch)>) {
63+ return env_needs_get_scheduler<Env>{};
64+ } else {
65+ return ::beman::execution26::continues_on (
66+ ::beman::execution26::starts_on (::beman::execution26::detail::forward_like<OutSndr>(data),
67+ ::beman::execution26::detail::forward_like<OutSndr>(child)),
68+ ::std::move(sch));
69+ }
70+ } else {
71+ auto & [sch, closure] = data;
72+ auto orig_sch{::beman::execution26::detail::query_with_default (
73+ ::beman::execution26::get_completion_scheduler<::beman::execution26::set_value_t >,
74+ ::beman::execution26::get_env (child),
75+ ::beman::execution26::detail::query_with_default(
76+ ::beman::execution26::get_scheduler, env, not_a_scheduler{}))};
77+
78+ if constexpr (::std::same_as<not_a_scheduler, decltype (orig_sch)>) {
79+ return env_needs_get_scheduler<Env>{};
80+ } else {
81+ return ::beman::execution26::detail::write_env (
82+ ::beman::execution26::continues_on (
83+ ::beman::execution26::detail::forward_like<OutSndr>(closure)(
84+ ::beman::execution26::continues_on (
85+ ::beman::execution26::detail::write_env (
86+ ::beman::execution26::detail::forward_like<OutSndr>(child),
87+ ::beman::execution26::detail::sched_env(orig_sch)),
88+ sch)),
89+ orig_sch),
90+ ::beman::execution26::detail::sched_env(env));
91+ }
92+ }
93+ }
94+
4395 template <::beman::execution26::scheduler Sch, ::beman::execution26::sender Sndr>
4496 requires ::beman::execution26::detail::is_sender_adaptor_closure<Sndr>
4597 auto operator ()(Sch&&, Sndr&&) const -> void =
@@ -72,7 +124,35 @@ struct on_t {
72124 ::beman::execution26::detail::product_type{::std::forward<Sch>(sch), ::std::forward<Closure>(closure)},
73125 ::std::forward<Sndr>(sndr)));
74126 }
127+ template <::beman::execution26::scheduler Sch, ::beman::execution26::detail::is_sender_adaptor_closure Closure>
128+ auto operator ()(Sch&& sch, Closure&& closure) const {
129+ return ::beman::execution26::detail::sender_adaptor{
130+ *this , ::std::forward<Sch>(sch), ::std::forward<Closure>(closure)};
131+ }
132+ };
133+
134+ #if 0
135+ template <typename Data, typename Sender, typename Env>
136+ struct completion_signatures_for_impl<
137+ ::beman::execution26::detail::basic_sender<::beman::execution26::detail::on_t, Data, Sender>,
138+ Env> {
139+ //-dk:TODO pick up scheduler errors and merge them in?
140+ using type =
141+ #if 0
142+ ::beman::execution26::detail::meta::combine<
143+ ::beman::execution26::completion_signatures_of_t<Sender, Env>,
144+ ::beman::execution26::completion_signatures<::beman::execution26::set_error_t(::std::exception_ptr)>
145+ >
146+ #else
147+ ::beman::execution26::completion_signatures<
148+ ::beman::execution26::set_value_t(),
149+ ::beman::execution26::set_error_t(::std::exception_ptr)
150+ >
151+ #endif
152+ ;
75153};
154+ #endif
155+
76156} // namespace beman::execution26::detail
77157
78158namespace beman ::execution26 {
0 commit comments