1 /*
2  * Copyright (c) 2023 NVIDIA Corporation
3  *
4  * Licensed under the Apache License Version 2.0 with LLVM Exceptions
5  * (the "License"); you may not use this file except in compliance with
6  * the License. You may obtain a copy of the License at
7  *
8  *   https://llvm.org/LICENSE.txt
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #pragma once
17 
18 #include "__concepts.hpp"
19 #include "__config.hpp"
20 #include "__meta.hpp"
21 #include "__type_traits.hpp"
22 
23 namespace stdexec
24 {
25 struct __none_such;
26 
27 //////////////////////////////////////////////////////////////////////////////////////////////////
28 struct default_domain;
29 
30 //////////////////////////////////////////////////////////////////////////////////////////////////
31 namespace __rcvrs
32 {
33 struct set_value_t;
34 struct set_error_t;
35 struct set_stopped_t;
36 } // namespace __rcvrs
37 
38 using __rcvrs::set_error_t;
39 using __rcvrs::set_stopped_t;
40 using __rcvrs::set_value_t;
41 extern const set_value_t set_value;
42 extern const set_error_t set_error;
43 extern const set_stopped_t set_stopped;
44 
45 template <class _Tag>
46 concept __completion_tag =
47     __one_of<_Tag, set_value_t, set_error_t, set_stopped_t>;
48 
49 struct receiver_t;
50 
51 template <class _Sender>
52 extern const bool enable_receiver;
53 
54 namespace __env
55 {
56 template <class _Query, class _Value>
57 struct prop;
58 
59 template <class... _Envs>
60 struct env;
61 } // namespace __env
62 
63 using __env::env;
64 using __env::prop;
65 using empty_env = env<>;
66 
67 //////////////////////////////////////////////////////////////////////////////////////////////////
68 namespace __get_env
69 {
70 struct get_env_t;
71 } // namespace __get_env
72 
73 using __get_env::get_env_t;
74 extern const get_env_t get_env;
75 
76 template <class _EnvProvider>
77 using env_of_t = __call_result_t<get_env_t, _EnvProvider>;
78 
79 //////////////////////////////////////////////////////////////////////////////////////////////////
80 enum class forward_progress_guarantee
81 {
82     concurrent,
83     parallel,
84     weakly_parallel
85 };
86 
87 namespace __queries
88 {
89 struct forwarding_query_t;
90 struct execute_may_block_caller_t;
91 struct get_forward_progress_guarantee_t;
92 struct __has_algorithm_customizations_t;
93 struct get_scheduler_t;
94 struct get_delegatee_scheduler_t;
95 struct get_allocator_t;
96 struct get_stop_token_t;
97 template <__completion_tag _CPO>
98 struct get_completion_scheduler_t;
99 } // namespace __queries
100 
101 using __queries::__has_algorithm_customizations_t;
102 using __queries::execute_may_block_caller_t;
103 using __queries::forwarding_query_t;
104 using __queries::get_allocator_t;
105 using __queries::get_completion_scheduler_t;
106 using __queries::get_delegatee_scheduler_t;
107 using __queries::get_forward_progress_guarantee_t;
108 using __queries::get_scheduler_t;
109 using __queries::get_stop_token_t;
110 
111 extern const forwarding_query_t forwarding_query;
112 extern const execute_may_block_caller_t execute_may_block_caller;
113 extern const __has_algorithm_customizations_t __has_algorithm_customizations;
114 extern const get_forward_progress_guarantee_t get_forward_progress_guarantee;
115 extern const get_scheduler_t get_scheduler;
116 extern const get_delegatee_scheduler_t get_delegatee_scheduler;
117 extern const get_allocator_t get_allocator;
118 extern const get_stop_token_t get_stop_token;
119 template <__completion_tag _CPO>
120 extern const get_completion_scheduler_t<_CPO> get_completion_scheduler;
121 
122 struct never_stop_token;
123 class inplace_stop_source;
124 class inplace_stop_token;
125 template <class _Fn>
126 class inplace_stop_callback;
127 
128 template <class _Tp>
129 using stop_token_of_t = __decay_t<__call_result_t<get_stop_token_t, _Tp>>;
130 
131 template <class _Sender, class _CPO>
132 concept __has_completion_scheduler =
133     __callable<get_completion_scheduler_t<_CPO>, env_of_t<const _Sender&>>;
134 
135 template <class _Sender, class _CPO>
136 using __completion_scheduler_for =
137     __call_result_t<get_completion_scheduler_t<_CPO>, env_of_t<const _Sender&>>;
138 
139 //////////////////////////////////////////////////////////////////////////////////////////////////
140 namespace __sigs
141 {
142 template <class _Sig>
143 inline constexpr bool __is_compl_sig = false;
144 
145 struct get_completion_signatures_t;
146 } // namespace __sigs
147 
148 template <class _Sig>
149 concept __completion_signature = __sigs::__is_compl_sig<_Sig>;
150 
151 template <class... _Sigs>
152 struct completion_signatures;
153 
154 using __sigs::get_completion_signatures_t;
155 extern const get_completion_signatures_t get_completion_signatures;
156 
157 template <class _Sender, class... _Env>
158 using __completion_signatures_of_t = //
159     __call_result_t<get_completion_signatures_t, _Sender, _Env...>;
160 
161 //////////////////////////////////////////////////////////////////////////////////////////////////
162 namespace __connect
163 {
164 struct connect_t;
165 } // namespace __connect
166 
167 using __connect::connect_t;
168 extern const connect_t connect;
169 
170 template <class _Sender, class _Receiver>
171 using connect_result_t = __call_result_t<connect_t, _Sender, _Receiver>;
172 
173 template <class _Sender, class _Receiver>
174 concept __nothrow_connectable =
175     __nothrow_callable<connect_t, _Sender, _Receiver>;
176 
177 struct sender_t;
178 
179 template <class _Sender>
180 extern const bool enable_sender;
181 
182 //////////////////////////////////////////////////////////////////////////////////////////////////
183 namespace __start
184 {
185 struct start_t;
186 } // namespace __start
187 
188 using __start::start_t;
189 extern const start_t start;
190 
191 //////////////////////////////////////////////////////////////////////////////////////////////////
192 namespace __sched
193 {
194 struct schedule_t;
195 } // namespace __sched
196 
197 using __sched::schedule_t;
198 extern const schedule_t schedule;
199 
200 //////////////////////////////////////////////////////////////////////////////////////////////////
201 namespace __as_awaitable
202 {
203 struct as_awaitable_t;
204 } // namespace __as_awaitable
205 
206 using __as_awaitable::as_awaitable_t;
207 extern const as_awaitable_t as_awaitable;
208 
209 //////////////////////////////////////////////////////////////////////////////////////////////////
210 namespace __start_on
211 {
212 struct start_on_t;
213 } // namespace __start_on
214 
215 using __start_on::start_on_t;
216 extern const start_on_t start_on;
217 
218 using on_t = start_on_t;
219 extern const on_t on;
220 
221 //////////////////////////////////////////////////////////////////////////////////////////////////
222 namespace __continue_on
223 {
224 struct continue_on_t;
225 } // namespace __continue_on
226 
227 using __continue_on::continue_on_t;
228 extern const continue_on_t continue_on;
229 
230 using transfer_t = continue_on_t;
231 extern const transfer_t transfer;
232 
233 //////////////////////////////////////////////////////////////////////////////////////////////////
234 namespace __transfer_just
235 {
236 struct transfer_just_t;
237 } // namespace __transfer_just
238 
239 using __transfer_just::transfer_just_t;
240 extern const transfer_just_t transfer_just;
241 
242 //////////////////////////////////////////////////////////////////////////////////////////////////
243 namespace __bulk
244 {
245 struct bulk_t;
246 } // namespace __bulk
247 
248 using __bulk::bulk_t;
249 extern const bulk_t bulk;
250 
251 //////////////////////////////////////////////////////////////////////////////////////////////////
252 namespace __split
253 {
254 struct split_t;
255 struct __split_t;
256 } // namespace __split
257 
258 using __split::split_t;
259 extern const split_t split;
260 
261 //////////////////////////////////////////////////////////////////////////////////////////////////
262 namespace __ensure_started
263 {
264 struct ensure_started_t;
265 struct __ensure_started_t;
266 } // namespace __ensure_started
267 
268 using __ensure_started::ensure_started_t;
269 extern const ensure_started_t ensure_started;
270 
271 //////////////////////////////////////////////////////////////////////////////////////////////////
272 namespace __on_v2
273 {
274 struct on_t;
275 } // namespace __on_v2
276 
277 namespace v2
278 {
279 using __on_v2::on_t;
280 } // namespace v2
281 
282 namespace __detail
283 {
284 struct __sexpr_apply_t;
285 } // namespace __detail
286 
287 using __detail::__sexpr_apply_t;
288 extern const __sexpr_apply_t __sexpr_apply;
289 } // namespace stdexec
290 
291 template <class...>
__print()292 [[deprecated]] void __print()
293 {}
294 
295 template <class...>
296 struct __undef;
297