]>
Commit | Line | Data |
---|---|---|
b32b8144 FG |
1 | // |
2 | // system_executor.hpp | |
3 | // ~~~~~~~~~~~~~~~~~~~ | |
4 | // | |
1e59de90 | 5 | // Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com) |
b32b8144 FG |
6 | // |
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | |
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
9 | // | |
10 | ||
11 | #ifndef BOOST_ASIO_SYSTEM_EXECUTOR_HPP | |
12 | #define BOOST_ASIO_SYSTEM_EXECUTOR_HPP | |
13 | ||
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) | |
15 | # pragma once | |
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) | |
17 | ||
18 | #include <boost/asio/detail/config.hpp> | |
20effc67 TL |
19 | #include <boost/asio/detail/memory.hpp> |
20 | #include <boost/asio/execution.hpp> | |
b32b8144 FG |
21 | |
22 | #include <boost/asio/detail/push_options.hpp> | |
23 | ||
24 | namespace boost { | |
25 | namespace asio { | |
26 | ||
27 | class system_context; | |
28 | ||
29 | /// An executor that uses arbitrary threads. | |
30 | /** | |
31 | * The system executor represents an execution context where functions are | |
20effc67 TL |
32 | * permitted to run on arbitrary threads. When the blocking.never property is |
33 | * established, the system executor will schedule the function to run on an | |
34 | * unspecified system thread pool. When either blocking.possibly or | |
35 | * blocking.always is established, the executor invokes the function | |
36 | * immediately. | |
b32b8144 | 37 | */ |
20effc67 TL |
38 | template <typename Blocking, typename Relationship, typename Allocator> |
39 | class basic_system_executor | |
b32b8144 FG |
40 | { |
41 | public: | |
20effc67 TL |
42 | /// Default constructor. |
43 | basic_system_executor() BOOST_ASIO_NOEXCEPT | |
44 | : allocator_(Allocator()) | |
45 | { | |
46 | } | |
47 | ||
1e59de90 TL |
48 | #if !defined(GENERATING_DOCUMENTATION) |
49 | private: | |
50 | friend struct boost_asio_require_fn::impl; | |
51 | friend struct boost_asio_prefer_fn::impl; | |
52 | #endif // !defined(GENERATING_DOCUMENTATION) | |
53 | ||
20effc67 TL |
54 | /// Obtain an executor with the @c blocking.possibly property. |
55 | /** | |
56 | * Do not call this function directly. It is intended for use with the | |
57 | * boost::asio::require customisation point. | |
58 | * | |
59 | * For example: | |
60 | * @code boost::asio::system_executor ex1; | |
61 | * auto ex2 = boost::asio::require(ex1, | |
62 | * boost::asio::execution::blocking.possibly); @endcode | |
63 | */ | |
64 | basic_system_executor<execution::blocking_t::possibly_t, | |
65 | Relationship, Allocator> | |
66 | require(execution::blocking_t::possibly_t) const | |
67 | { | |
68 | return basic_system_executor<execution::blocking_t::possibly_t, | |
69 | Relationship, Allocator>(allocator_); | |
70 | } | |
71 | ||
72 | /// Obtain an executor with the @c blocking.always property. | |
73 | /** | |
74 | * Do not call this function directly. It is intended for use with the | |
75 | * boost::asio::require customisation point. | |
76 | * | |
77 | * For example: | |
78 | * @code boost::asio::system_executor ex1; | |
79 | * auto ex2 = boost::asio::require(ex1, | |
80 | * boost::asio::execution::blocking.always); @endcode | |
81 | */ | |
82 | basic_system_executor<execution::blocking_t::always_t, | |
83 | Relationship, Allocator> | |
84 | require(execution::blocking_t::always_t) const | |
85 | { | |
86 | return basic_system_executor<execution::blocking_t::always_t, | |
87 | Relationship, Allocator>(allocator_); | |
88 | } | |
89 | ||
90 | /// Obtain an executor with the @c blocking.never property. | |
91 | /** | |
92 | * Do not call this function directly. It is intended for use with the | |
93 | * boost::asio::require customisation point. | |
94 | * | |
95 | * For example: | |
96 | * @code boost::asio::system_executor ex1; | |
97 | * auto ex2 = boost::asio::require(ex1, | |
98 | * boost::asio::execution::blocking.never); @endcode | |
99 | */ | |
100 | basic_system_executor<execution::blocking_t::never_t, | |
101 | Relationship, Allocator> | |
102 | require(execution::blocking_t::never_t) const | |
103 | { | |
104 | return basic_system_executor<execution::blocking_t::never_t, | |
105 | Relationship, Allocator>(allocator_); | |
106 | } | |
107 | ||
108 | /// Obtain an executor with the @c relationship.continuation property. | |
109 | /** | |
110 | * Do not call this function directly. It is intended for use with the | |
111 | * boost::asio::require customisation point. | |
112 | * | |
113 | * For example: | |
114 | * @code boost::asio::system_executor ex1; | |
115 | * auto ex2 = boost::asio::require(ex1, | |
116 | * boost::asio::execution::relationship.continuation); @endcode | |
117 | */ | |
118 | basic_system_executor<Blocking, | |
119 | execution::relationship_t::continuation_t, Allocator> | |
120 | require(execution::relationship_t::continuation_t) const | |
121 | { | |
122 | return basic_system_executor<Blocking, | |
123 | execution::relationship_t::continuation_t, Allocator>(allocator_); | |
124 | } | |
125 | ||
126 | /// Obtain an executor with the @c relationship.fork property. | |
127 | /** | |
128 | * Do not call this function directly. It is intended for use with the | |
129 | * boost::asio::require customisation point. | |
130 | * | |
131 | * For example: | |
132 | * @code boost::asio::system_executor ex1; | |
133 | * auto ex2 = boost::asio::require(ex1, | |
134 | * boost::asio::execution::relationship.fork); @endcode | |
135 | */ | |
136 | basic_system_executor<Blocking, | |
137 | execution::relationship_t::fork_t, Allocator> | |
138 | require(execution::relationship_t::fork_t) const | |
139 | { | |
140 | return basic_system_executor<Blocking, | |
141 | execution::relationship_t::fork_t, Allocator>(allocator_); | |
142 | } | |
143 | ||
144 | /// Obtain an executor with the specified @c allocator property. | |
145 | /** | |
146 | * Do not call this function directly. It is intended for use with the | |
147 | * boost::asio::require customisation point. | |
148 | * | |
149 | * For example: | |
150 | * @code boost::asio::system_executor ex1; | |
151 | * auto ex2 = boost::asio::require(ex1, | |
152 | * boost::asio::execution::allocator(my_allocator)); @endcode | |
153 | */ | |
154 | template <typename OtherAllocator> | |
155 | basic_system_executor<Blocking, Relationship, OtherAllocator> | |
156 | require(execution::allocator_t<OtherAllocator> a) const | |
157 | { | |
158 | return basic_system_executor<Blocking, | |
159 | Relationship, OtherAllocator>(a.value()); | |
160 | } | |
161 | ||
162 | /// Obtain an executor with the default @c allocator property. | |
163 | /** | |
164 | * Do not call this function directly. It is intended for use with the | |
165 | * boost::asio::require customisation point. | |
166 | * | |
167 | * For example: | |
168 | * @code boost::asio::system_executor ex1; | |
169 | * auto ex2 = boost::asio::require(ex1, | |
170 | * boost::asio::execution::allocator); @endcode | |
171 | */ | |
172 | basic_system_executor<Blocking, Relationship, std::allocator<void> > | |
173 | require(execution::allocator_t<void>) const | |
174 | { | |
175 | return basic_system_executor<Blocking, | |
176 | Relationship, std::allocator<void> >(); | |
177 | } | |
178 | ||
1e59de90 TL |
179 | #if !defined(GENERATING_DOCUMENTATION) |
180 | private: | |
181 | friend struct boost_asio_query_fn::impl; | |
182 | friend struct boost::asio::execution::detail::blocking_t<0>; | |
183 | friend struct boost::asio::execution::detail::mapping_t<0>; | |
184 | friend struct boost::asio::execution::detail::outstanding_work_t<0>; | |
185 | friend struct boost::asio::execution::detail::relationship_t<0>; | |
186 | #endif // !defined(GENERATING_DOCUMENTATION) | |
187 | ||
20effc67 TL |
188 | /// Query the current value of the @c mapping property. |
189 | /** | |
190 | * Do not call this function directly. It is intended for use with the | |
191 | * boost::asio::query customisation point. | |
192 | * | |
193 | * For example: | |
194 | * @code boost::asio::system_executor ex; | |
195 | * if (boost::asio::query(ex, boost::asio::execution::mapping) | |
196 | * == boost::asio::execution::mapping.thread) | |
197 | * ... @endcode | |
198 | */ | |
199 | static BOOST_ASIO_CONSTEXPR execution::mapping_t query( | |
200 | execution::mapping_t) BOOST_ASIO_NOEXCEPT | |
201 | { | |
202 | return execution::mapping.thread; | |
203 | } | |
204 | ||
205 | /// Query the current value of the @c context property. | |
206 | /** | |
207 | * Do not call this function directly. It is intended for use with the | |
208 | * boost::asio::query customisation point. | |
209 | * | |
210 | * For example: | |
211 | * @code boost::asio::system_executor ex; | |
212 | * boost::asio::system_context& pool = boost::asio::query( | |
213 | * ex, boost::asio::execution::context); @endcode | |
214 | */ | |
215 | static system_context& query(execution::context_t) BOOST_ASIO_NOEXCEPT; | |
216 | ||
217 | /// Query the current value of the @c blocking property. | |
218 | /** | |
219 | * Do not call this function directly. It is intended for use with the | |
220 | * boost::asio::query customisation point. | |
221 | * | |
222 | * For example: | |
223 | * @code boost::asio::system_executor ex; | |
224 | * if (boost::asio::query(ex, boost::asio::execution::blocking) | |
225 | * == boost::asio::execution::blocking.always) | |
226 | * ... @endcode | |
227 | */ | |
228 | static BOOST_ASIO_CONSTEXPR execution::blocking_t query( | |
229 | execution::blocking_t) BOOST_ASIO_NOEXCEPT | |
230 | { | |
231 | return Blocking(); | |
232 | } | |
233 | ||
234 | /// Query the current value of the @c relationship property. | |
235 | /** | |
236 | * Do not call this function directly. It is intended for use with the | |
237 | * boost::asio::query customisation point. | |
238 | * | |
239 | * For example: | |
240 | * @code boost::asio::system_executor ex; | |
241 | * if (boost::asio::query(ex, boost::asio::execution::relationship) | |
242 | * == boost::asio::execution::relationship.continuation) | |
243 | * ... @endcode | |
244 | */ | |
245 | static BOOST_ASIO_CONSTEXPR execution::relationship_t query( | |
246 | execution::relationship_t) BOOST_ASIO_NOEXCEPT | |
247 | { | |
248 | return Relationship(); | |
249 | } | |
250 | ||
251 | /// Query the current value of the @c allocator property. | |
252 | /** | |
253 | * Do not call this function directly. It is intended for use with the | |
254 | * boost::asio::query customisation point. | |
255 | * | |
256 | * For example: | |
257 | * @code boost::asio::system_executor ex; | |
258 | * auto alloc = boost::asio::query(ex, | |
259 | * boost::asio::execution::allocator); @endcode | |
260 | */ | |
261 | template <typename OtherAllocator> | |
262 | BOOST_ASIO_CONSTEXPR Allocator query( | |
263 | execution::allocator_t<OtherAllocator>) const BOOST_ASIO_NOEXCEPT | |
264 | { | |
265 | return allocator_; | |
266 | } | |
267 | ||
268 | /// Query the current value of the @c allocator property. | |
269 | /** | |
270 | * Do not call this function directly. It is intended for use with the | |
271 | * boost::asio::query customisation point. | |
272 | * | |
273 | * For example: | |
274 | * @code boost::asio::system_executor ex; | |
275 | * auto alloc = boost::asio::query(ex, | |
276 | * boost::asio::execution::allocator); @endcode | |
277 | */ | |
278 | BOOST_ASIO_CONSTEXPR Allocator query( | |
279 | execution::allocator_t<void>) const BOOST_ASIO_NOEXCEPT | |
280 | { | |
281 | return allocator_; | |
282 | } | |
283 | ||
284 | /// Query the occupancy (recommended number of work items) for the system | |
285 | /// context. | |
286 | /** | |
287 | * Do not call this function directly. It is intended for use with the | |
288 | * boost::asio::query customisation point. | |
289 | * | |
290 | * For example: | |
291 | * @code boost::asio::system_executor ex; | |
292 | * std::size_t occupancy = boost::asio::query( | |
293 | * ex, boost::asio::execution::occupancy); @endcode | |
294 | */ | |
295 | std::size_t query(execution::occupancy_t) const BOOST_ASIO_NOEXCEPT; | |
296 | ||
1e59de90 | 297 | public: |
20effc67 TL |
298 | /// Compare two executors for equality. |
299 | /** | |
300 | * Two executors are equal if they refer to the same underlying io_context. | |
301 | */ | |
302 | friend bool operator==(const basic_system_executor&, | |
303 | const basic_system_executor&) BOOST_ASIO_NOEXCEPT | |
304 | { | |
305 | return true; | |
306 | } | |
307 | ||
308 | /// Compare two executors for inequality. | |
309 | /** | |
310 | * Two executors are equal if they refer to the same underlying io_context. | |
311 | */ | |
312 | friend bool operator!=(const basic_system_executor&, | |
313 | const basic_system_executor&) BOOST_ASIO_NOEXCEPT | |
314 | { | |
315 | return false; | |
316 | } | |
317 | ||
1e59de90 TL |
318 | #if !defined(GENERATING_DOCUMENTATION) |
319 | private: | |
320 | friend struct boost_asio_execution_execute_fn::impl; | |
321 | #endif // !defined(GENERATING_DOCUMENTATION) | |
322 | ||
20effc67 TL |
323 | /// Execution function. |
324 | /** | |
325 | * Do not call this function directly. It is intended for use with the | |
326 | * execution::execute customisation point. | |
327 | * | |
328 | * For example: | |
329 | * @code boost::asio::system_executor ex; | |
330 | * execution::execute(ex, my_function_object); @endcode | |
331 | */ | |
332 | template <typename Function> | |
333 | void execute(BOOST_ASIO_MOVE_ARG(Function) f) const | |
334 | { | |
335 | this->do_execute(BOOST_ASIO_MOVE_CAST(Function)(f), Blocking()); | |
336 | } | |
337 | ||
338 | #if !defined(BOOST_ASIO_NO_TS_EXECUTORS) | |
1e59de90 | 339 | public: |
b32b8144 FG |
340 | /// Obtain the underlying execution context. |
341 | system_context& context() const BOOST_ASIO_NOEXCEPT; | |
342 | ||
343 | /// Inform the executor that it has some outstanding work to do. | |
344 | /** | |
345 | * For the system executor, this is a no-op. | |
346 | */ | |
347 | void on_work_started() const BOOST_ASIO_NOEXCEPT | |
348 | { | |
349 | } | |
350 | ||
351 | /// Inform the executor that some work is no longer outstanding. | |
352 | /** | |
353 | * For the system executor, this is a no-op. | |
354 | */ | |
355 | void on_work_finished() const BOOST_ASIO_NOEXCEPT | |
356 | { | |
357 | } | |
358 | ||
359 | /// Request the system executor to invoke the given function object. | |
360 | /** | |
361 | * This function is used to ask the executor to execute the given function | |
362 | * object. The function object will always be executed inside this function. | |
363 | * | |
364 | * @param f The function object to be called. The executor will make | |
365 | * a copy of the handler object as required. The function signature of the | |
366 | * function object must be: @code void function(); @endcode | |
367 | * | |
368 | * @param a An allocator that may be used by the executor to allocate the | |
369 | * internal storage needed for function invocation. | |
370 | */ | |
20effc67 TL |
371 | template <typename Function, typename OtherAllocator> |
372 | void dispatch(BOOST_ASIO_MOVE_ARG(Function) f, const OtherAllocator& a) const; | |
b32b8144 FG |
373 | |
374 | /// Request the system executor to invoke the given function object. | |
375 | /** | |
376 | * This function is used to ask the executor to execute the given function | |
377 | * object. The function object will never be executed inside this function. | |
378 | * Instead, it will be scheduled to run on an unspecified system thread pool. | |
379 | * | |
380 | * @param f The function object to be called. The executor will make | |
381 | * a copy of the handler object as required. The function signature of the | |
382 | * function object must be: @code void function(); @endcode | |
383 | * | |
384 | * @param a An allocator that may be used by the executor to allocate the | |
385 | * internal storage needed for function invocation. | |
386 | */ | |
20effc67 TL |
387 | template <typename Function, typename OtherAllocator> |
388 | void post(BOOST_ASIO_MOVE_ARG(Function) f, const OtherAllocator& a) const; | |
b32b8144 FG |
389 | |
390 | /// Request the system executor to invoke the given function object. | |
391 | /** | |
392 | * This function is used to ask the executor to execute the given function | |
393 | * object. The function object will never be executed inside this function. | |
394 | * Instead, it will be scheduled to run on an unspecified system thread pool. | |
395 | * | |
396 | * @param f The function object to be called. The executor will make | |
397 | * a copy of the handler object as required. The function signature of the | |
398 | * function object must be: @code void function(); @endcode | |
399 | * | |
400 | * @param a An allocator that may be used by the executor to allocate the | |
401 | * internal storage needed for function invocation. | |
402 | */ | |
20effc67 TL |
403 | template <typename Function, typename OtherAllocator> |
404 | void defer(BOOST_ASIO_MOVE_ARG(Function) f, const OtherAllocator& a) const; | |
405 | #endif // !defined(BOOST_ASIO_NO_TS_EXECUTORS) | |
b32b8144 | 406 | |
20effc67 TL |
407 | private: |
408 | template <typename, typename, typename> friend class basic_system_executor; | |
409 | ||
410 | // Constructor used by require(). | |
411 | basic_system_executor(const Allocator& a) | |
412 | : allocator_(a) | |
b32b8144 | 413 | { |
b32b8144 FG |
414 | } |
415 | ||
20effc67 TL |
416 | /// Execution helper implementation for the possibly blocking property. |
417 | template <typename Function> | |
418 | void do_execute(BOOST_ASIO_MOVE_ARG(Function) f, | |
419 | execution::blocking_t::possibly_t) const; | |
420 | ||
421 | /// Execution helper implementation for the always blocking property. | |
422 | template <typename Function> | |
423 | void do_execute(BOOST_ASIO_MOVE_ARG(Function) f, | |
424 | execution::blocking_t::always_t) const; | |
425 | ||
426 | /// Execution helper implementation for the never blocking property. | |
427 | template <typename Function> | |
428 | void do_execute(BOOST_ASIO_MOVE_ARG(Function) f, | |
429 | execution::blocking_t::never_t) const; | |
430 | ||
431 | // The allocator used for execution functions. | |
432 | Allocator allocator_; | |
433 | }; | |
434 | ||
435 | /// An executor that uses arbitrary threads. | |
436 | /** | |
437 | * The system executor represents an execution context where functions are | |
438 | * permitted to run on arbitrary threads. When the blocking.never property is | |
439 | * established, the system executor will schedule the function to run on an | |
440 | * unspecified system thread pool. When either blocking.possibly or | |
441 | * blocking.always is established, the executor invokes the function | |
442 | * immediately. | |
443 | */ | |
444 | typedef basic_system_executor<execution::blocking_t::possibly_t, | |
445 | execution::relationship_t::fork_t, std::allocator<void> > | |
446 | system_executor; | |
447 | ||
448 | #if !defined(GENERATING_DOCUMENTATION) | |
449 | ||
450 | namespace traits { | |
451 | ||
452 | #if !defined(BOOST_ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) | |
453 | ||
454 | template <typename Blocking, typename Relationship, typename Allocator> | |
455 | struct equality_comparable< | |
456 | boost::asio::basic_system_executor<Blocking, Relationship, Allocator> | |
457 | > | |
458 | { | |
459 | BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true); | |
460 | BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true); | |
461 | }; | |
462 | ||
463 | #endif // !defined(BOOST_ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT) | |
464 | ||
465 | #if !defined(BOOST_ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) | |
466 | ||
467 | template <typename Blocking, typename Relationship, | |
468 | typename Allocator, typename Function> | |
469 | struct execute_member< | |
470 | boost::asio::basic_system_executor<Blocking, Relationship, Allocator>, | |
471 | Function | |
472 | > | |
473 | { | |
474 | BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true); | |
475 | BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false); | |
476 | typedef void result_type; | |
477 | }; | |
478 | ||
479 | #endif // !defined(BOOST_ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) | |
480 | ||
481 | #if !defined(BOOST_ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT) | |
482 | ||
483 | template <typename Blocking, typename Relationship, typename Allocator> | |
484 | struct require_member< | |
485 | boost::asio::basic_system_executor<Blocking, Relationship, Allocator>, | |
486 | boost::asio::execution::blocking_t::possibly_t | |
487 | > | |
488 | { | |
489 | BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true); | |
490 | BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false); | |
491 | typedef boost::asio::basic_system_executor< | |
492 | boost::asio::execution::blocking_t::possibly_t, | |
493 | Relationship, Allocator> result_type; | |
494 | }; | |
495 | ||
496 | template <typename Blocking, typename Relationship, typename Allocator> | |
497 | struct require_member< | |
498 | boost::asio::basic_system_executor<Blocking, Relationship, Allocator>, | |
499 | boost::asio::execution::blocking_t::always_t | |
500 | > | |
501 | { | |
502 | BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true); | |
503 | BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false); | |
504 | typedef boost::asio::basic_system_executor< | |
505 | boost::asio::execution::blocking_t::always_t, | |
506 | Relationship, Allocator> result_type; | |
507 | }; | |
508 | ||
509 | template <typename Blocking, typename Relationship, typename Allocator> | |
510 | struct require_member< | |
511 | boost::asio::basic_system_executor<Blocking, Relationship, Allocator>, | |
512 | boost::asio::execution::blocking_t::never_t | |
513 | > | |
514 | { | |
515 | BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true); | |
516 | BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false); | |
517 | typedef boost::asio::basic_system_executor< | |
518 | boost::asio::execution::blocking_t::never_t, | |
519 | Relationship, Allocator> result_type; | |
520 | }; | |
521 | ||
522 | template <typename Blocking, typename Relationship, typename Allocator> | |
523 | struct require_member< | |
524 | boost::asio::basic_system_executor<Blocking, Relationship, Allocator>, | |
525 | boost::asio::execution::relationship_t::fork_t | |
526 | > | |
527 | { | |
528 | BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true); | |
529 | BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false); | |
530 | typedef boost::asio::basic_system_executor<Blocking, | |
531 | boost::asio::execution::relationship_t::fork_t, | |
532 | Allocator> result_type; | |
533 | }; | |
534 | ||
535 | template <typename Blocking, typename Relationship, typename Allocator> | |
536 | struct require_member< | |
537 | boost::asio::basic_system_executor<Blocking, Relationship, Allocator>, | |
538 | boost::asio::execution::relationship_t::continuation_t | |
539 | > | |
540 | { | |
541 | BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true); | |
542 | BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false); | |
543 | typedef boost::asio::basic_system_executor<Blocking, | |
544 | boost::asio::execution::relationship_t::continuation_t, | |
545 | Allocator> result_type; | |
546 | }; | |
547 | ||
548 | template <typename Blocking, typename Relationship, typename Allocator> | |
549 | struct require_member< | |
550 | boost::asio::basic_system_executor<Blocking, Relationship, Allocator>, | |
551 | boost::asio::execution::allocator_t<void> | |
552 | > | |
553 | { | |
554 | BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true); | |
555 | BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false); | |
556 | typedef boost::asio::basic_system_executor<Blocking, | |
557 | Relationship, std::allocator<void> > result_type; | |
558 | }; | |
559 | ||
560 | template <typename Blocking, typename Relationship, | |
561 | typename Allocator, typename OtherAllocator> | |
562 | struct require_member< | |
563 | boost::asio::basic_system_executor<Blocking, Relationship, Allocator>, | |
564 | boost::asio::execution::allocator_t<OtherAllocator> | |
565 | > | |
566 | { | |
567 | BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true); | |
568 | BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false); | |
569 | typedef boost::asio::basic_system_executor<Blocking, | |
570 | Relationship, OtherAllocator> result_type; | |
571 | }; | |
572 | ||
573 | #endif // !defined(BOOST_ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT) | |
574 | ||
575 | #if !defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT) | |
576 | ||
577 | template <typename Blocking, typename Relationship, | |
578 | typename Allocator, typename Property> | |
579 | struct query_static_constexpr_member< | |
580 | boost::asio::basic_system_executor<Blocking, Relationship, Allocator>, | |
581 | Property, | |
582 | typename boost::asio::enable_if< | |
583 | boost::asio::is_convertible< | |
584 | Property, | |
585 | boost::asio::execution::mapping_t | |
586 | >::value | |
587 | >::type | |
588 | > | |
589 | { | |
590 | BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true); | |
591 | BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true); | |
592 | typedef boost::asio::execution::mapping_t::thread_t result_type; | |
593 | ||
594 | static BOOST_ASIO_CONSTEXPR result_type value() BOOST_ASIO_NOEXCEPT | |
b32b8144 | 595 | { |
20effc67 | 596 | return result_type(); |
b32b8144 FG |
597 | } |
598 | }; | |
599 | ||
20effc67 TL |
600 | #endif // !defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT) |
601 | ||
602 | #if !defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT) | |
603 | ||
604 | template <typename Blocking, typename Relationship, | |
605 | typename Allocator, typename Property> | |
606 | struct query_member< | |
607 | boost::asio::basic_system_executor<Blocking, Relationship, Allocator>, | |
608 | Property, | |
609 | typename boost::asio::enable_if< | |
610 | boost::asio::is_convertible< | |
611 | Property, | |
612 | boost::asio::execution::blocking_t | |
613 | >::value | |
614 | >::type | |
615 | > | |
616 | { | |
617 | BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true); | |
618 | BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true); | |
619 | typedef boost::asio::execution::blocking_t result_type; | |
620 | }; | |
621 | ||
622 | template <typename Blocking, typename Relationship, | |
623 | typename Allocator, typename Property> | |
624 | struct query_member< | |
625 | boost::asio::basic_system_executor<Blocking, Relationship, Allocator>, | |
626 | Property, | |
627 | typename boost::asio::enable_if< | |
628 | boost::asio::is_convertible< | |
629 | Property, | |
630 | boost::asio::execution::relationship_t | |
631 | >::value | |
632 | >::type | |
633 | > | |
634 | { | |
635 | BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true); | |
636 | BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true); | |
637 | typedef boost::asio::execution::relationship_t result_type; | |
638 | }; | |
639 | ||
640 | template <typename Blocking, typename Relationship, typename Allocator> | |
641 | struct query_member< | |
642 | boost::asio::basic_system_executor<Blocking, Relationship, Allocator>, | |
643 | boost::asio::execution::context_t | |
644 | > | |
645 | { | |
646 | BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true); | |
647 | BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true); | |
648 | typedef boost::asio::system_context& result_type; | |
649 | }; | |
650 | ||
651 | template <typename Blocking, typename Relationship, typename Allocator> | |
652 | struct query_member< | |
653 | boost::asio::basic_system_executor<Blocking, Relationship, Allocator>, | |
654 | boost::asio::execution::allocator_t<void> | |
655 | > | |
656 | { | |
657 | BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true); | |
658 | BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true); | |
659 | typedef Allocator result_type; | |
660 | }; | |
661 | ||
662 | template <typename Blocking, typename Relationship, typename Allocator> | |
663 | struct query_member< | |
664 | boost::asio::basic_system_executor<Blocking, Relationship, Allocator>, | |
665 | boost::asio::execution::allocator_t<Allocator> | |
666 | > | |
667 | { | |
668 | BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true); | |
669 | BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true); | |
670 | typedef Allocator result_type; | |
671 | }; | |
672 | ||
673 | #endif // !defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT) | |
674 | ||
675 | } // namespace traits | |
676 | ||
677 | #endif // !defined(GENERATING_DOCUMENTATION) | |
678 | ||
b32b8144 FG |
679 | } // namespace asio |
680 | } // namespace boost | |
681 | ||
682 | #include <boost/asio/detail/pop_options.hpp> | |
683 | ||
684 | #include <boost/asio/impl/system_executor.hpp> | |
685 | ||
686 | #endif // BOOST_ASIO_SYSTEM_EXECUTOR_HPP |