Description
split_t
struct split_t
{
template <snd::sender Sndr>
requires(snd::sender_in<Sndr, split_env>)
auto operator()(Sndr &&sndr) const // noexcept
{
auto dom = snd::general::get_domain_early(std::as_const(sndr));
return snd::transform_sender(
dom, snd::make_sender(*this, {}, std::forward<Sndr>(sndr)));
}
template <snd::sender Sndr>
auto transform_sender(Sndr &&sndr) noexcept // NOLINT
requires(snd::sender_for<decltype((sndr)), split_t>)
{
// TODO(mcs):
// Note: tag_change: split_t => split_impl_tag
// Note: data_change: {} => shared_wrapper(shared_state{child},old_tag)
// Note: sh_state: shared_state<child_sndr> conflict shared_state<Sndr>
auto &&[old_tag, _, child] = sndr;
auto *sh_state =
new __split::shared_state{std::forward_like<decltype(sndr)>(child)};
return snd::make_sender(split_impl_tag(),
__split::shared_wrapper{sh_state, old_tag});
}
};
inline constexpr split_t split{}; // NOLINT
local_state
template <class Sndr, class Rcvr>
struct local_state : local_state_base
{ // exposition only
using onstopcallback = // Note: Rcvr + get_stop_token_t => token_type
stop_callback_of_t<queries::stop_token_of_t<queries::env_of_t<Rcvr>>,
snd::general::on_stop_request>;
~local_state() noexcept override;
void notify() noexcept override;
local_state(Sndr &&sndr, Rcvr &rcvr) noexcept;
local_state(local_state &&) = delete;
local_state(const local_state &) = delete;
local_state &operator=(local_state &&) = delete;
local_state &operator=(const local_state &) = delete;
std::optional<onstopcallback> on_stop; // exposition only // NOLINT
// using Childen = snd::__detail::mate_type::child_type<Sndr>;
shared_state<Sndr> *sh_state; // exposition only // NOLINT
Rcvr *rcvr; // exposition only // NOLINT
};
template <> // for tag: adapt::split_impl_tag
struct snd::general::impls_for<adapt::split_impl_tag> : snd::__detail::default_impls
{
// Note: create [basic_state->state] when connect.
static constexpr auto get_state = // NOLINT
[]<class Sndr>(Sndr &&sndr, auto &rcvr) noexcept {
// Note: call: local_state(sndr,rcvr)
return adapt::__split::local_state{std::forward_like<Sndr>(sndr), rcvr};
};
....
}
p2300R10
local-state(Sndr&& sndr, Rcvr& rcvr) noexcept;
Effects: Equivalent to:
// when tag is split_impl_tag
auto& [_, data, _] = sndr; //snd::make_sender(split_impl_tag(),__split::shared_wrapper{sh_state, old_tag}); //only can bind 2 but 3
this->sh_state = data.sh_state.get(); //shared_state<child_sndr> conflict shared_state<Sndr>
this->sh_state->inc-ref();
this->rcvr = addressof(rcvr);
info
sender auto input = just(1);
sender auto multi_shot = split(std::move(input));
sender auto start =
then(multi_shot, [](int i) { std::cout << i << " First continuation\n"; });
sync_wait(std::move(start));
`
e:\0_github_project\mcsexec\mcsexec\test\test_base\split.cpp:79:32: required from here
79 | mcs::this_thread::sync_wait(std::move(start));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
E:/0_github_project/mcsexec/mcsexec/include/__detail/adapt/__split.hpp:254:35: error: cannot convert 'mcs::execution::adapt::__split::shared_state<mcs::execution::snd::__detail::basic_sender<mcs::execution::factories::__just_tmcs::execution::recv::set_value_t, mcs::execution::snd::__detail::product_type > >' to 'mcs::execution::adapt::__split::shared_state<mcs::execution::snd::__detail::basic_sender<mcs::execution::adapt::split_impl_tag, mcs::execution::adapt::__split::shared_wrapper<mcs::execution::adapt::__split::shared_state<mcs::execution::snd::__detail::basic_sender<mcs::execution::factories::__just_tmcs::execution::recv::set_value_t, mcs::execution::snd::__detail::product_type > >, mcs::execution::adapt::split_t> > >' in assignment
254 | this->sh_state = data.sh_state; // TODO(mcs): ? ~~~~~^~~~~~~~
| |
| mcs::execution::adapt::__split::shared_state<mcs::execution::snd::__detail::basic_sender<mcs::execution::factories::__just_tmcs::execution::recv::set_value_t, mcs::execution::snd::__detail::product_type > >*
`