Skip to content

Commit

Permalink
use the transform_completion_signatures implementation from ustdex
Browse files Browse the repository at this point in the history
  • Loading branch information
ericniebler committed May 24, 2024
1 parent 68ef470 commit 23da2e3
Show file tree
Hide file tree
Showing 69 changed files with 1,203 additions and 1,043 deletions.
13 changes: 6 additions & 7 deletions examples/algorithms/retry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,12 @@ struct _retry_sender {
using _value = stdexec::completion_signatures<stdexec::set_value_t(Ts...)>;

template <class Env>
auto get_completion_signatures(Env&&) const
-> stdexec::make_completion_signatures<
S&,
Env,
stdexec::completion_signatures<stdexec::set_error_t(std::exception_ptr)>,
_value,
_error> {
auto get_completion_signatures(Env&&) const -> stdexec::transform_completion_signatures_of<
S&,
Env,
stdexec::completion_signatures<stdexec::set_error_t(std::exception_ptr)>,
_value,
_error> {
return {};
}

Expand Down
5 changes: 2 additions & 3 deletions examples/benchmark/static_thread_pool_old.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ namespace exec_old {
stdexec::__mbind_front_q<bulk_non_throwing, Fun, Shape>,
stdexec::__q<stdexec::__mand>>>,
stdexec::completion_signatures<>,
stdexec::__with_exception_ptr>;
stdexec::__eptr_completion>;

template <class... Tys>
using set_value_t =
Expand Down Expand Up @@ -489,8 +489,7 @@ namespace exec_old {
}

template <stdexec::__decays_to<bulk_sender> Self, class Env>
static auto get_completion_signatures(Self&&, Env&&)
-> completion_signatures<Self, Env> {
static auto get_completion_signatures(Self&&, Env&&) -> completion_signatures<Self, Env> {
return {};
}

Expand Down
2 changes: 1 addition & 1 deletion include/exec/any_sender_of.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,7 @@ namespace exec {

template <auto... _SchedulerQueries>
class any_scheduler {
using __schedule_completions = stdexec::__concat_completion_signatures_t<
using __schedule_completions = stdexec::__concat_completion_signatures<
_Completions,
stdexec::completion_signatures<stdexec::set_value_t()>>;
using __schedule_receiver = any_receiver_ref<__schedule_completions, _ReceiverQueries...>;
Expand Down
2 changes: 1 addition & 1 deletion include/exec/async_scope.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ namespace exec {

template <class _Sender, class _Env>
using __future_completions_t = //
make_completion_signatures<
transform_completion_signatures_of<
_Sender,
__env_t<_Env>,
completion_signatures<set_stopped_t(), set_error_t(std::exception_ptr)>,
Expand Down
21 changes: 1 addition & 20 deletions include/exec/finally.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,7 @@ namespace exec {
using namespace stdexec;

template <class _Sigs>
using __value_types_ =
__gather_signal<set_value_t, _Sigs, __mbind_front_q<__decayed_tuple, set_value_t>, __q<__types>>;

template <class _Sigs>
using __error_types_ =
__gather_signal<set_error_t, _Sigs, __mbind_front_q<__decayed_tuple, set_error_t>, __q<__types>>;

template <class _Sigs>
using __stopped_types_ = __gather_signal<
set_stopped_t,
_Sigs,
__mbind_front_q<__decayed_tuple, set_stopped_t>,
__q<__types>>;

template <class _Sigs>
using __result_variant = __minvoke<
__mconcat<__q<__variant>>,
__value_types_<_Sigs>,
__error_types_<_Sigs>,
__stopped_types_<_Sigs>>;
using __result_variant = __for_each_completion_signature<_Sigs, __decayed_tuple, __variant>;

template <class _ResultType, class _ReceiverId>
struct __final_operation_base {
Expand Down
2 changes: 1 addition & 1 deletion include/exec/into_tuple.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace exec {

template <class _Sender, class _Env>
using __try_result_tuple_t = //
__try_value_types_of_t<_Sender, _Env, __q<__decayed_tuple>, __q<__msingle>>;
__value_types_of_t<_Sender, _Env, __q<__decayed_tuple>, __q<__msingle>>;

template <class _Sender, class _Env>
using __result_tuple_t = //
Expand Down
2 changes: 1 addition & 1 deletion include/exec/libdispatch_queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ namespace exec {
stdexec::__mbind_front_q<bulk_non_throwing, Fun, Shape>,
stdexec::__q<stdexec::__mand>>>,
stdexec::completion_signatures<>,
stdexec::__with_exception_ptr>;
stdexec::__eptr_completion>;

template <class... Tys>
using set_value_t =
Expand Down
33 changes: 20 additions & 13 deletions include/exec/materialize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ namespace exec {
class __t {
public:
using receiver_concept = stdexec::receiver_t;
using __id = __receiver;

__t(_Receiver&& __upstream)
: __upstream_{static_cast<_Receiver&&>(__upstream)} {
Expand Down Expand Up @@ -70,6 +71,7 @@ namespace exec {
class __t {
public:
using sender_concept = stdexec::sender_t;
using __id = __sender;

template <__decays_to<_Sender> _Sndr>
__t(_Sndr&& __sender)
Expand All @@ -94,17 +96,17 @@ namespace exec {
using __materialize_error = completion_signatures<set_value_t(set_error_t, _Err)>;

template <class _Env>
using __completion_signatures_for_t = make_completion_signatures<
_Sender,
_Env,
completion_signatures<>,
__materialize_value,
__materialize_error,
completion_signatures<set_value_t(set_stopped_t)>>;
using __completion_signatures_for_t = //
__transform_completion_signatures<
__completion_signatures_of_t<_Sender, _Env>,
__materialize_value,
__materialize_error,
completion_signatures<set_value_t(set_stopped_t)>,
__mappend_into_q<completion_signatures>::__f>;

template <__decays_to<__t> _Self, class _Env>
static auto
get_completion_signatures(_Self&&, _Env) -> __completion_signatures_for_t<_Env> {
static auto get_completion_signatures(_Self&&, _Env&&) //
-> __completion_signatures_for_t<_Env> {
return {};
}

Expand Down Expand Up @@ -140,6 +142,7 @@ namespace exec {
class __t {
public:
using receiver_concept = stdexec::receiver_t;
using __id = __receiver;

__t(_Receiver&& __upstream)
: __upstream_{static_cast<_Receiver&&>(__upstream)} {
Expand Down Expand Up @@ -179,6 +182,7 @@ namespace exec {
class __t {
public:
using sender_concept = stdexec::sender_t;
using __id = __sender;

template <__decays_to<_Sender> _Sndr>
__t(_Sndr&& __sndr) noexcept(__nothrow_decay_copyable<_Sndr>)
Expand All @@ -201,12 +205,15 @@ namespace exec {
using __dematerialize_value = completion_signatures<__decay_t<_Tag>(_Args...)>;

template <class _Env>
using __completion_signatures_for_t =
make_completion_signatures<_Sender, _Env, completion_signatures<>, __dematerialize_value>;
using __completion_signatures_for_t = __try_make_completion_signatures<
_Sender,
_Env,
completion_signatures<>,
__q<__dematerialize_value>>;

template <__decays_to<__t> _Self, class _Env>
static auto
get_completion_signatures(_Self&&, _Env) -> __completion_signatures_for_t<_Env> {
static auto get_completion_signatures(_Self&&, _Env&&) //
-> __completion_signatures_for_t<_Env> {
return {};
}

Expand Down
4 changes: 2 additions & 2 deletions include/exec/repeat_effect_until.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ namespace exec {
stdexec::__try_make_completion_signatures<
stdexec::schedule_result_t<exec::trampoline_scheduler>,
_Env,
__with_exception_ptr,
__q<__compl_sigs::__default_set_value>,
__eptr_completion,
__q<__sigs::__default_set_value>,
__q<__error_t>>,
__mbind_front_q<__values_t, _Sender>,
__q<__error_t>>;
Expand Down
4 changes: 2 additions & 2 deletions include/exec/repeat_n.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ namespace exec {
stdexec::__try_make_completion_signatures<
stdexec::schedule_result_t<exec::trampoline_scheduler>,
_Env,
__with_exception_ptr,
__q<__compl_sigs::__default_set_value>,
__eptr_completion,
__q<__sigs::__default_set_value>,
__q<__error_t>>,
__mbind_front_q<__values_t, decltype(__decay_t<_Pair>::__child_)>,
__q<__error_t>>;
Expand Down
16 changes: 8 additions & 8 deletions include/exec/sequence/any_sequence_of.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ namespace exec {

template <class _Sigs, class... _Queries>
struct __env {
using __compl_sigs = __to_sequence_completions_t<_Sigs>;
using __sigs = __to_sequence_completions_t<_Sigs>;

using __vtable_t = stdexec::__t<__next_vtable<_Sigs, __compl_sigs, _Queries...>>;
using __vtable_t = stdexec::__t<__next_vtable<_Sigs, __sigs, _Queries...>>;

struct __t {
using __id = __env;
Expand All @@ -109,11 +109,11 @@ namespace exec {
using __return_sigs = completion_signatures<set_value_t(), set_stopped_t()>;
using __void_sender = typename any_receiver_ref<__return_sigs>::template any_sender<>;
using __next_sigs = completion_signatures<_Sigs...>;
using __compl_sigs = __to_sequence_completions_t<__next_sigs>;
using __sigs = __to_sequence_completions_t<__next_sigs>;
using __item_sender = typename any_receiver_ref<__next_sigs>::template any_sender<>;
using __item_types = item_types<__item_sender>;

using __vtable_t = stdexec::__t<__next_vtable<__next_sigs, __compl_sigs, _Queries...>>;
using __vtable_t = stdexec::__t<__next_vtable<__next_sigs, __sigs, _Queries...>>;

template <class Sig>
using __vfun = __any_::__rcvr_vfun<Sig>;
Expand Down Expand Up @@ -144,14 +144,14 @@ namespace exec {
}

template <class Error>
requires __v<__mapply<__contains<set_error_t(Error)>, __compl_sigs>>
requires __v<__mapply<__contains<set_error_t(Error)>, __sigs>>
void set_error(Error&& __error) noexcept {
(*static_cast<const __vfun<set_error_t(Error)>*>(__env_.__vtable_)->__complete_)(
__env_.__rcvr_, static_cast<Error&&>(__error));
}

void set_stopped() noexcept
requires __v<__mapply<__contains<set_stopped_t()>, __compl_sigs>>
requires __v<__mapply<__contains<set_stopped_t()>, __sigs>>
{
(*static_cast<const __vfun<set_stopped_t()>*>(__env_.__vtable_)->__complete_)(
__env_.__rcvr_);
Expand Down Expand Up @@ -231,13 +231,13 @@ namespace exec {
using __receiver_ref_t = stdexec::__t<__next_receiver_ref<_Sigs, _ReceiverQueries>>;
using __vtable_t = stdexec::__t<__sender_vtable<_Sigs, _SenderQueries, _ReceiverQueries>>;

using __compl_sigs = __to_sequence_completions_t<_Sigs>;
using __sigs = __to_sequence_completions_t<_Sigs>;
using __item_sender = typename any_receiver_ref<_Sigs>::template any_sender<>;

class __t {
public:
using __id = __sequence_sender;
using completion_signatures = __compl_sigs;
using completion_signatures = __sigs;
using item_types = exec::item_types<__item_sender>;
using sender_concept = sequence_sender_t;

Expand Down
17 changes: 10 additions & 7 deletions include/exec/sequence/ignore_all_values.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,18 @@ namespace exec {
};
};

template <class _Tag, class _Sigs>
using __gather_types =
__gather_signal<_Tag, _Sigs, __mbind_front_q<__decayed_tuple, _Tag>, __q<__types>>;
template <class _Tag>
using __result_tuple_fn = //
__mcompose_q<__types_ref, __mbind_front_q<__decayed_tuple, _Tag>::template __f>;

template <class _Sigs>
using __result_variant_ = __minvoke<
__mconcat<__nullable_variant_t>,
__gather_types<set_error_t, _Sigs>,
__gather_types<set_stopped_t, _Sigs>>;
using __result_variant_ = //
__transform_completion_signatures<
_Sigs,
__mconst<__types_ref<>>::__f,
__mcompose_q<__types_ref, __mbind_front_q<__decayed_tuple, set_error_t>::__f>::__f,
__types_ref<std::tuple<set_stopped_t>>,
__mappend_into_q<__nullable_variant_fn::__f>::__f>;

template <class _Sender, class _Env>
using __result_variant_t =
Expand Down
54 changes: 24 additions & 30 deletions include/exec/sequence_senders.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,46 +243,40 @@ namespace exec {
stdexec::receiver<_Receiver> && //
__sequence_receiver_of<_Receiver, _SequenceItems>;

template <class _Items, class _Env>
using __concat_item_signatures_t = stdexec::__mapply<
stdexec::__q<stdexec::__concat_completion_signatures_t>,
stdexec::__mapply<
stdexec::__transform<stdexec::__mbind_back_q<stdexec::completion_signatures_of_t, _Env>>,
_Items>>;

template <class _Completions>
using __gather_error_signals = stdexec::__only_gather_signal<stdexec::set_error_t, _Completions>;

template <class _Completions>
using __gather_stopped_signals =
stdexec::__only_gather_signal<stdexec::set_stopped_t, _Completions>;

template <class _Completions>
using __to_sequence_completions_t = stdexec::__concat_completion_signatures_t<
stdexec::completion_signatures<stdexec::set_value_t()>,
__gather_error_signals<_Completions>,
__gather_stopped_signals<_Completions>>;
using __to_sequence_completions_t = //
stdexec::__transform_completion_signatures<
_Completions,
stdexec::__mconst<stdexec::completion_signatures<stdexec::set_value_t()>>::__f,
stdexec::__sigs::__default_set_error,
stdexec::completion_signatures<stdexec::set_stopped_t()>,
stdexec::__concat_completion_signatures>;

template <class _Sender, class _Env>
using __to_sequence_completion_signatures = stdexec::make_completion_signatures<
_Sender,
_Env,
stdexec::completion_signatures<stdexec::set_value_t()>,
stdexec::__mconst<stdexec::completion_signatures<>>::__f>;

using __item_completion_signatures = //
stdexec::transform_completion_signatures_of<
_Sender,
_Env,
stdexec::completion_signatures<stdexec::set_value_t()>,
stdexec::__mconst<stdexec::completion_signatures<>>::__f>;

template <class _Sequence, class _Env>
using __sequence_completion_signatures_of_t = stdexec::__concat_completion_signatures_t<
using __sequence_completion_signatures = //
stdexec::__try_make_completion_signatures<
_Sequence,
_Env,
stdexec::completion_signatures<stdexec::set_value_t()>,
stdexec::__mconst<stdexec::completion_signatures<>>>,
stdexec::__mconst<stdexec::completion_signatures<>>>;

template <class _Sequence, class _Env>
using __sequence_completion_signatures_of_t = //
stdexec::__mapply<
stdexec::__q<stdexec::__concat_completion_signatures_t>,
stdexec::__mapply<
stdexec::__transform<stdexec::__mbind_back_q<__to_sequence_completion_signatures, _Env>>,
item_types_of_t<_Sequence, _Env>>>>;
stdexec::__transform<
stdexec::__mbind_back_q<__item_completion_signatures, _Env>,
stdexec::__mbind_back<
stdexec::__mtry_q<stdexec::__concat_completion_signatures>,
__sequence_completion_signatures<_Sequence, _Env>>>,
item_types_of_t<_Sequence, _Env>>;

template <class _Receiver, class _Sender>
concept sequence_receiver_from = //
Expand Down
2 changes: 1 addition & 1 deletion include/exec/static_thread_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ namespace exec {
__v<
__value_types_of_t<Sender, Env, __mbind_front_q<bulk_non_throwing, Fun, Shape>, __q<__mand>>>,
completion_signatures<>,
__with_exception_ptr>;
__eptr_completion>;

template <class... Tys>
using set_value_t = completion_signatures<set_value_t(stdexec::__decay_t<Tys>...)>;
Expand Down
2 changes: 1 addition & 1 deletion include/exec/system_context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ namespace exec {
class system_bulk_sender {
/// Meta-function that returns the completion signatures of `this`.
template <typename _Self, typename _Env>
using __completions_t = stdexec::make_completion_signatures< //
using __completions_t = stdexec::transform_completion_signatures_of< //
stdexec::__copy_cvref_t<_Self, _Previous>, //
_Env, //
stdexec::completion_signatures<stdexec::set_error_t(std::exception_ptr)> //
Expand Down
5 changes: 3 additions & 2 deletions include/exec/variant_sender.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ namespace exec {
template <class... _SenderIds>
struct __sender {
template <class _Self, class _Env>
using __completion_signatures_t = __concat_completion_signatures_t<
__completion_signatures_of_t<__copy_cvref_t<_Self, stdexec::__t<_SenderIds>>, _Env>...>;
using __completion_signatures_t = //
__mtry_q<stdexec::__concat_completion_signatures>::__f<
__completion_signatures_of_t<__copy_cvref_t<_Self, stdexec::__t<_SenderIds>>, _Env>...>;

template <class _Self, class _Receiver>
struct __visitor {
Expand Down
Loading

0 comments on commit 23da2e3

Please sign in to comment.