Skip to content

Commit

Permalink
Merge pull request #1190 from NVIDIA/tidy-create
Browse files Browse the repository at this point in the history
remove uses of `__x` from create.hpp
  • Loading branch information
ericniebler authored Jan 5, 2024
2 parents bf0166b + d885656 commit 358b47d
Showing 1 changed file with 38 additions and 30 deletions.
68 changes: 38 additions & 30 deletions include/exec/create.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,54 +38,62 @@ namespace exec {

template <class _ReceiverId, class _Fun, class _ArgsId>
struct __operation {
using _Context = __context<__t<_ReceiverId>, __t<_ArgsId>>;
using _Context = __context<stdexec::__t<_ReceiverId>, stdexec::__t<_ArgsId>>;
using _Result = __call_result_t<_Fun, _Context&>;
using _State = __if_c<same_as<_Result, void>, __void, std::optional<_Result>>;

STDEXEC_ATTRIBUTE((no_unique_address)) _Context __ctx_;
STDEXEC_ATTRIBUTE((no_unique_address)) _Fun __fun_;
STDEXEC_ATTRIBUTE((no_unique_address)) _State __state_{};
struct __t {
using __id = __operation;

friend void tag_invoke(start_t, __operation& __self) noexcept {
__self.__state_.emplace(__conv{[&]() noexcept {
return ((_Fun&&) __self.__fun_)(__self.__ctx_);
}});
}
STDEXEC_ATTRIBUTE((no_unique_address)) _Context __ctx_;
STDEXEC_ATTRIBUTE((no_unique_address)) _Fun __fun_;
STDEXEC_ATTRIBUTE((no_unique_address)) _State __state_{};

friend void tag_invoke(start_t, __t& __self) noexcept {
__self.__state_.emplace(__conv{[&]() noexcept {
return ((_Fun&&) __self.__fun_)(__self.__ctx_);
}});
}
};
};

template <class _Fun, class _ArgsId, class... _Sigs>
struct __sender {
using _Args = __t<_ArgsId>;
using sender_concept = stdexec::sender_t;
using completion_signatures = stdexec::completion_signatures<_Sigs...>;
using _Args = stdexec::__t<_ArgsId>;

_Fun __fun_;
_Args __args_;
struct __t {
using __id = __sender;
using sender_concept = stdexec::sender_t;
using completion_signatures = stdexec::completion_signatures<_Sigs...>;

template <__decays_to<__sender> _Self, receiver_of<completion_signatures> _Receiver>
requires __callable<_Fun, __context<_Receiver, _Args>&>
&& constructible_from<_Fun, __copy_cvref_t<_Self, _Fun>>
&& constructible_from<_Args, __copy_cvref_t<_Self, _Args>>
friend auto tag_invoke(connect_t, _Self&& __self, _Receiver __rcvr)
-> __operation<__x<_Receiver>, _Fun, _ArgsId> {
static_assert(__nothrow_callable<_Fun, __context<_Receiver, _Args>&>);
return {
{(_Receiver&&) __rcvr, ((_Self&&) __self).__args_},
((_Self&&) __self).__fun_
};
}
_Fun __fun_;
_Args __args_;

friend empty_env tag_invoke(get_env_t, const __sender&) noexcept {
return {};
}
template <__decays_to<__t> _Self, receiver_of<completion_signatures> _Receiver>
requires __callable<_Fun, __context<_Receiver, _Args>&>
&& constructible_from<_Fun, __copy_cvref_t<_Self, _Fun>>
&& constructible_from<_Args, __copy_cvref_t<_Self, _Args>>
friend auto tag_invoke(connect_t, _Self&& __self, _Receiver __rcvr)
-> stdexec::__t<__operation<stdexec::__id<_Receiver>, _Fun, _ArgsId>> {
static_assert(__nothrow_callable<_Fun, __context<_Receiver, _Args>&>);
return {
{(_Receiver&&) __rcvr, ((_Self&&) __self).__args_},
((_Self&&) __self).__fun_
};
}

friend empty_env tag_invoke(get_env_t, const __t&) noexcept {
return {};
}
};
};

template <__completion_signature... _Sigs>
struct __create_t {
template <class _Fun, class... _Args>
requires move_constructible<_Fun> && constructible_from<__decayed_tuple<_Args...>, _Args...>
auto operator()(_Fun __fun, _Args&&... __args) const
-> __sender<_Fun, __x<__decayed_tuple<_Args...>>, _Sigs...> {
-> __t<__sender<_Fun, __id<__decayed_tuple<_Args...>>, _Sigs...>> {
return {(_Fun&&) __fun, {(_Args&&) __args...}};
}
};
Expand Down

0 comments on commit 358b47d

Please sign in to comment.