1*5cee9157SPatrick Williams /* 2*5cee9157SPatrick Williams * Copyright (c) 2021-2024 NVIDIA Corporation 3*5cee9157SPatrick Williams * 4*5cee9157SPatrick Williams * Licensed under the Apache License Version 2.0 with LLVM Exceptions 5*5cee9157SPatrick Williams * (the "License"); you may not use this file except in compliance with 6*5cee9157SPatrick Williams * the License. You may obtain a copy of the License at 7*5cee9157SPatrick Williams * 8*5cee9157SPatrick Williams * https://llvm.org/LICENSE.txt 9*5cee9157SPatrick Williams * 10*5cee9157SPatrick Williams * Unless required by applicable law or agreed to in writing, software 11*5cee9157SPatrick Williams * distributed under the License is distributed on an "AS IS" BASIS, 12*5cee9157SPatrick Williams * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*5cee9157SPatrick Williams * See the License for the specific language governing permissions and 14*5cee9157SPatrick Williams * limitations under the License. 15*5cee9157SPatrick Williams */ 16*5cee9157SPatrick Williams #pragma once 17*5cee9157SPatrick Williams 18*5cee9157SPatrick Williams #include "__basic_sender.hpp" 19*5cee9157SPatrick Williams #include "__cpo.hpp" 20*5cee9157SPatrick Williams #include "__env.hpp" 21*5cee9157SPatrick Williams #include "__execution_fwd.hpp" 22*5cee9157SPatrick Williams #include "__receivers.hpp" 23*5cee9157SPatrick Williams #include "__schedulers.hpp" 24*5cee9157SPatrick Williams #include "__utility.hpp" 25*5cee9157SPatrick Williams 26*5cee9157SPatrick Williams namespace stdexec 27*5cee9157SPatrick Williams { 28*5cee9157SPatrick Williams namespace __inln 29*5cee9157SPatrick Williams { 30*5cee9157SPatrick Williams struct __schedule_t 31*5cee9157SPatrick Williams {}; 32*5cee9157SPatrick Williams 33*5cee9157SPatrick Williams struct __scheduler 34*5cee9157SPatrick Williams { 35*5cee9157SPatrick Williams using __t = __scheduler; 36*5cee9157SPatrick Williams using __id = __scheduler; 37*5cee9157SPatrick Williams 38*5cee9157SPatrick Williams template <class _Tag = __schedule_t> 39*5cee9157SPatrick Williams STDEXEC_ATTRIBUTE((host, device)) STDEXEC_MEMFN_DECLstdexec::__inln::__scheduler40*5cee9157SPatrick Williams STDEXEC_MEMFN_DECL(auto schedule)(this __scheduler) 41*5cee9157SPatrick Williams { 42*5cee9157SPatrick Williams return __make_sexpr<_Tag>(); 43*5cee9157SPatrick Williams } 44*5cee9157SPatrick Williams querystdexec::__inln::__scheduler45*5cee9157SPatrick Williams auto query(get_forward_progress_guarantee_t) const noexcept 46*5cee9157SPatrick Williams -> forward_progress_guarantee 47*5cee9157SPatrick Williams { 48*5cee9157SPatrick Williams return forward_progress_guarantee::weakly_parallel; 49*5cee9157SPatrick Williams } 50*5cee9157SPatrick Williams 51*5cee9157SPatrick Williams auto operator==(const __scheduler&) const noexcept -> bool = default; 52*5cee9157SPatrick Williams }; 53*5cee9157SPatrick Williams 54*5cee9157SPatrick Williams struct __env 55*5cee9157SPatrick Williams { querystdexec::__inln::__env56*5cee9157SPatrick Williams static constexpr bool query(__is_scheduler_affine_t) noexcept 57*5cee9157SPatrick Williams { 58*5cee9157SPatrick Williams return true; 59*5cee9157SPatrick Williams } 60*5cee9157SPatrick Williams querystdexec::__inln::__env61*5cee9157SPatrick Williams constexpr auto query(get_completion_scheduler_t<set_value_t>) const noexcept 62*5cee9157SPatrick Williams -> __scheduler 63*5cee9157SPatrick Williams { 64*5cee9157SPatrick Williams return {}; 65*5cee9157SPatrick Williams } 66*5cee9157SPatrick Williams }; 67*5cee9157SPatrick Williams } // namespace __inln 68*5cee9157SPatrick Williams 69*5cee9157SPatrick Williams template <> 70*5cee9157SPatrick Williams struct __sexpr_impl<__inln::__schedule_t> : __sexpr_defaults 71*5cee9157SPatrick Williams { 72*5cee9157SPatrick Williams static constexpr auto get_attrs = // __anond6e5414a0102stdexec::__sexpr_impl73*5cee9157SPatrick Williams [](__ignore) noexcept { return __inln::__env(); }; 74*5cee9157SPatrick Williams 75*5cee9157SPatrick Williams static constexpr auto get_completion_signatures = // 76*5cee9157SPatrick Williams [](__ignore, __anond6e5414a0202stdexec::__sexpr_impl77*5cee9157SPatrick Williams __ignore = {}) noexcept -> completion_signatures<set_value_t()> { 78*5cee9157SPatrick Williams return {}; 79*5cee9157SPatrick Williams }; 80*5cee9157SPatrick Williams 81*5cee9157SPatrick Williams static constexpr auto start = // 82*5cee9157SPatrick Williams []<class _Receiver>(__ignore, _Receiver& __rcvr) noexcept -> void { 83*5cee9157SPatrick Williams stdexec::set_value(static_cast<_Receiver&&>(__rcvr)); 84*5cee9157SPatrick Williams }; 85*5cee9157SPatrick Williams }; 86*5cee9157SPatrick Williams 87*5cee9157SPatrick Williams static_assert(__is_scheduler_affine<schedule_result_t<__inln::__scheduler>>); 88*5cee9157SPatrick Williams } // namespace stdexec 89