From cc719130257589e9726c3c55ca4b50500856e73f Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Thu, 22 Jan 2026 10:21:35 -0800 Subject: [PATCH] remove unused `__any_receiver_ref` --- include/exec/any_sender_of.hpp | 45 +++++-- include/exec/sequence/any_sequence_of.hpp | 6 +- .../stdexec/__detail/__any_receiver_ref.hpp | 120 ------------------ include/stdexec/__detail/__let.hpp | 1 - include/stdexec/__detail/__task_scheduler.hpp | 4 +- include/stdexec/execution.hpp | 1 - 6 files changed, 37 insertions(+), 140 deletions(-) delete mode 100644 include/stdexec/__detail/__any_receiver_ref.hpp diff --git a/include/exec/any_sender_of.hpp b/include/exec/any_sender_of.hpp index 21e59438e..bfcdd5da0 100644 --- a/include/exec/any_sender_of.hpp +++ b/include/exec/any_sender_of.hpp @@ -15,7 +15,6 @@ */ #pragma once -#include "../stdexec/__detail/__any_receiver_ref.hpp" #include "../stdexec/execution.hpp" #include "sequence_senders.hpp" @@ -27,6 +26,26 @@ namespace exec { namespace __any { using namespace STDEXEC; + template + struct __rcvr_vfun; + + template + struct __rcvr_vfun<_Tag(_Args...)> { + void (*__complete_)(void*, _Args...) noexcept; + + void operator()(void* __obj, _Tag, _Args... __args) const noexcept { + __complete_(__obj, static_cast<_Args&&>(__args)...); + } + }; + + template + constexpr auto __rcvr_vfun_fn(_Obj*, _Tag (*)(_Args...)) noexcept { + return +[](void* __ptr, _Args... __args) noexcept { + _Obj* __obj = static_cast<_Obj*>(__ptr); + _Tag()(std::move(_GetReceiver()(*__obj)), static_cast<_Args&&>(__args)...); + }; + } + struct __create_vtable_t { template constexpr auto operator()(__mtype<_VTable>, __mtype<_Tp>) const noexcept -> const _VTable* { @@ -656,19 +675,19 @@ namespace exec { template struct __vtable, _Queries...> { struct __t - : __overload<__any_::__rcvr_vfun<_Sigs>...> + : __overload<__rcvr_vfun<_Sigs>...> , __query_vfun<_Queries>... { using __query_vfun<_Queries>::operator()...; template requires __one_of<_Tag(_As...), _Sigs...> - || __callable<__overload<__any_::__rcvr_vfun<_Sigs>...>, void*, _Tag, _As...> + || __callable<__overload<__rcvr_vfun<_Sigs>...>, void*, _Tag, _As...> void operator()(void* __rcvr, _Tag, _As&&... __as) const noexcept { if constexpr (__one_of<_Tag(_As...), _Sigs...>) { - const __any_::__rcvr_vfun<_Tag(_As...)>& __vfun = *this; + const __rcvr_vfun<_Tag(_As...)>& __vfun = *this; __vfun(__rcvr, _Tag(), static_cast<_As&&>(__as)...); } else { - const __overload<__any_::__rcvr_vfun<_Sigs>...>& __vfun = *this; + const __overload<__rcvr_vfun<_Sigs>...>& __vfun = *this; __vfun(__rcvr, _Tag(), static_cast<_As&&>(__as)...); } } @@ -678,7 +697,7 @@ namespace exec { && (__callable<__query_vfun_fn<_Rcvr>, _Queries> && ...) static auto __create_vtable(__mtype<_Rcvr>) noexcept -> const __t* { static const __t __vtable_{ - {{__any_::__rcvr_vfun_fn( + {{__rcvr_vfun_fn( static_cast<_Rcvr*>(nullptr), static_cast<_Sigs*>(nullptr))}...}, {__query_vfun_fn<_Rcvr>{}(static_cast<_Queries>(nullptr))}...}; return &__vtable_; @@ -791,26 +810,26 @@ namespace exec { template requires __one_of - || __callable<__overload<__any_::__rcvr_vfun<_Sigs>...>, void*, set_value_t, _As...> + || __callable<__overload<__rcvr_vfun<_Sigs>...>, void*, set_value_t, _As...> void set_value(_As&&... __as) noexcept { if constexpr (__one_of) { - const __any_::__rcvr_vfun& __vfun = *__env_.__vtable_; + const __rcvr_vfun& __vfun = *__env_.__vtable_; __vfun(__env_.__rcvr_, set_value_t(), static_cast<_As&&>(__as)...); } else { - const __overload<__any_::__rcvr_vfun<_Sigs>...>& __vfun = *__env_.__vtable_; + const __overload<__rcvr_vfun<_Sigs>...>& __vfun = *__env_.__vtable_; __vfun(__env_.__rcvr_, set_value_t(), static_cast<_As&&>(__as)...); } } template requires __one_of - || __callable<__overload<__any_::__rcvr_vfun<_Sigs>...>, void*, set_error_t, _Error> + || __callable<__overload<__rcvr_vfun<_Sigs>...>, void*, set_error_t, _Error> void set_error(_Error&& __err) noexcept { if constexpr (__one_of) { - const __any_::__rcvr_vfun& __vfun = *__env_.__vtable_; + const __rcvr_vfun& __vfun = *__env_.__vtable_; __vfun(__env_.__rcvr_, set_error_t(), static_cast<_Error&&>(__err)); } else { - const __overload<__any_::__rcvr_vfun<_Sigs>...>& __vfun = *__env_.__vtable_; + const __overload<__rcvr_vfun<_Sigs>...>& __vfun = *__env_.__vtable_; __vfun(__env_.__rcvr_, set_error_t(), static_cast<_Error&&>(__err)); } } @@ -818,7 +837,7 @@ namespace exec { void set_stopped() noexcept requires __one_of { - const __any_::__rcvr_vfun& __vfun = *__env_.__vtable_; + const __rcvr_vfun& __vfun = *__env_.__vtable_; __vfun(__env_.__rcvr_, set_stopped_t()); } diff --git a/include/exec/sequence/any_sequence_of.hpp b/include/exec/sequence/any_sequence_of.hpp index f7f034ae1..3d6e04fce 100644 --- a/include/exec/sequence/any_sequence_of.hpp +++ b/include/exec/sequence/any_sequence_of.hpp @@ -60,7 +60,7 @@ namespace exec { struct __t : public __rcvr_next_vfun<_NextSigs> - , public __any_::__rcvr_vfun<_Sigs>... + , public __rcvr_vfun<_Sigs>... , public __query_vfun<_Queries>... { using __id = __next_vtable; using __query_vfun<_Queries>::operator()...; @@ -71,7 +71,7 @@ namespace exec { static auto __create_vtable(__mtype<_Rcvr>) noexcept -> const __t* { static const __t __vtable_{ {__rcvr_next_vfun_fn<_Rcvr>{}(static_cast<_NextSigs*>(nullptr))}, - {__any_::__rcvr_vfun_fn( + {__rcvr_vfun_fn( static_cast<_Rcvr*>(nullptr), static_cast<_Sigs*>(nullptr))}..., {__query_vfun_fn<_Rcvr>{}(static_cast<_Queries>(nullptr))}...}; return &__vtable_; @@ -116,7 +116,7 @@ namespace exec { using __vtable_t = STDEXEC::__t<__next_vtable<__next_sigs, __sigs, _Queries...>>; template - using __vfun = __any_::__rcvr_vfun; + using __vfun = __rcvr_vfun; using __env_t = STDEXEC::__t<__env<__next_sigs, _Queries...>>; __env_t __env_; diff --git a/include/stdexec/__detail/__any_receiver_ref.hpp b/include/stdexec/__detail/__any_receiver_ref.hpp deleted file mode 100644 index 60342ee9b..000000000 --- a/include/stdexec/__detail/__any_receiver_ref.hpp +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2021-2024 NVIDIA Corporation - * - * Licensed under the Apache License Version 2.0 with LLVM Exceptions - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://llvm.org/LICENSE.txt - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#pragma once - -#include "__execution_fwd.hpp" - -#include "__completion_signatures.hpp" -#include "__receivers.hpp" - -#include - -namespace STDEXEC::__any_ { - template - struct __rcvr_vfun; - - template - struct __rcvr_vfun<_Tag(_Args...)> { - void (*__complete_)(void*, _Args...) noexcept; - - void operator()(void* __obj, _Tag, _Args... __args) const noexcept { - __complete_(__obj, static_cast<_Args&&>(__args)...); - } - }; - - template - constexpr auto __rcvr_vfun_fn(_Obj*, _Tag (*)(_Args...)) noexcept { - return +[](void* __ptr, _Args... __args) noexcept { - _Obj* __obj = static_cast<_Obj*>(__ptr); - _Tag()(std::move(_GetReceiver()(*__obj)), static_cast<_Args&&>(__args)...); - }; - } - - template - struct __receiver_vtable_for; - - template - struct __receiver_vtable_for, _Env> : __rcvr_vfun<_Sigs>... { - _Env (*__do_get_env)(const void* __op_state) noexcept; - - template - static auto __s_get_env(const void* __ptr) noexcept -> _Env { - auto* __op_state = static_cast(__ptr); - return _GetEnv()(*__op_state); - } - - template - explicit constexpr __receiver_vtable_for(_OpState* __op, _GetEnv, _GetReceiver = {}) noexcept - : __rcvr_vfun<_Sigs>{__rcvr_vfun_fn<_GetReceiver>(__op, static_cast<_Sigs*>(nullptr))}... - , __do_get_env{&__s_get_env<_OpState, _GetEnv>} { - } - - template - requires __one_of<_Tag(_Args...), _Sigs...> - void operator()(void* __obj, _Tag, _Args&&... __args) const noexcept { - const __rcvr_vfun<_Tag(_Args...)>& __vfun = *this; - __vfun(__obj, _Tag{}, static_cast<_Args&&>(__args)...); - } - - auto __get_env(const void* __op_state) const noexcept -> _Env { - return __do_get_env(__op_state); - } - }; - - template - inline constexpr __receiver_vtable_for<_Sigs, _Env> - __receiver_vtable_for_v{static_cast<_OpState*>(nullptr), _GetEnv{}, _GetReceiver{}}; - - template > - class __receiver_ref { - public: - using receiver_concept = receiver_t; - using __t = __receiver_ref; - using __id = __receiver_ref; - - template - __receiver_ref(_OpState& __op_state, _GetEnv, _GetReceiver = {}) noexcept - : __vtable_{&__any_::__receiver_vtable_for_v<_OpState, _GetEnv, _GetReceiver, _Env, _Sigs>} - , __op_state_{&__op_state} { - } - - auto get_env() const noexcept -> decltype(auto) { - return __vtable_->__get_env(__op_state_); - } - - template - requires __callable<__receiver_vtable_for<_Sigs, _Env>, void*, set_value_t, _As...> - void set_value(_As&&... __as) noexcept { - (*__vtable_)(__op_state_, set_value_t(), static_cast<_As&&>(__as)...); - } - - template - requires __callable<__receiver_vtable_for<_Sigs, _Env>, void*, set_error_t, _Error> - void set_error(_Error&& __err) noexcept { - (*__vtable_)(__op_state_, set_error_t(), static_cast<_Error&&>(__err)); - } - - void set_stopped() noexcept - requires __callable<__receiver_vtable_for<_Sigs, _Env>, void*, set_stopped_t> - { - (*__vtable_)(__op_state_, set_stopped_t()); - } - - private: - const __receiver_vtable_for<_Sigs, _Env>* __vtable_; - void* __op_state_; - }; -} // namespace STDEXEC::__any_ diff --git a/include/stdexec/__detail/__let.hpp b/include/stdexec/__detail/__let.hpp index 0e496f817..d58729ed3 100644 --- a/include/stdexec/__detail/__let.hpp +++ b/include/stdexec/__detail/__let.hpp @@ -18,7 +18,6 @@ #include "__execution_fwd.hpp" // include these after __execution_fwd.hpp -#include "__any_receiver_ref.hpp" // IWYU pragma: keep for __any::__receiver_ref #include "__basic_sender.hpp" #include "__diagnostics.hpp" #include "__domain.hpp" diff --git a/include/stdexec/__detail/__task_scheduler.hpp b/include/stdexec/__detail/__task_scheduler.hpp index b56dbce03..223e1586a 100644 --- a/include/stdexec/__detail/__task_scheduler.hpp +++ b/include/stdexec/__detail/__task_scheduler.hpp @@ -599,7 +599,7 @@ namespace STDEXEC { void schedule( system_context_replaceability::receiver_proxy& __rcvr_proxy, - std::span __storage) noexcept final override { + std::span __storage) noexcept final { __schedule(__rcvr_proxy, STDEXEC::schedule(__sch_), __storage); } @@ -615,7 +615,7 @@ namespace STDEXEC { void schedule_bulk_unchunked( size_t __size, system_context_replaceability::bulk_item_receiver_proxy& __rcvr_proxy, - std::span __storage) noexcept override { + std::span __storage) noexcept final { auto __sndr = STDEXEC::bulk_unchunked( STDEXEC::schedule(__sch_), par, __size, __detail::__bulk_unchunked_fn{__rcvr_proxy}); __schedule(__rcvr_proxy, std::move(__sndr), __storage); diff --git a/include/stdexec/execution.hpp b/include/stdexec/execution.hpp index d2b95932e..f102b0f7f 100644 --- a/include/stdexec/execution.hpp +++ b/include/stdexec/execution.hpp @@ -43,7 +43,6 @@ #include "__detail/__operation_states.hpp" #include "__detail/__read_env.hpp" #include "__detail/__receiver_adaptor.hpp" -#include "__detail/__receiver_ref.hpp" #include "__detail/__receivers.hpp" #include "__detail/__run_loop.hpp" #include "__detail/__schedule_from.hpp"