]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/asio/impl/compose.hpp
3df2f076128f8ec2dfd8822f72c62e6a92b86da6
[ceph.git] / ceph / src / boost / boost / asio / impl / compose.hpp
1 //
2 // impl/compose.hpp
3 // ~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
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_IMPL_COMPOSE_HPP
12 #define BOOST_ASIO_IMPL_COMPOSE_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>
19 #include <boost/asio/associated_executor.hpp>
20 #include <boost/asio/detail/base_from_cancellation_state.hpp>
21 #include <boost/asio/detail/handler_alloc_helpers.hpp>
22 #include <boost/asio/detail/handler_cont_helpers.hpp>
23 #include <boost/asio/detail/handler_invoke_helpers.hpp>
24 #include <boost/asio/detail/type_traits.hpp>
25 #include <boost/asio/detail/variadic_templates.hpp>
26 #include <boost/asio/execution/executor.hpp>
27 #include <boost/asio/execution/outstanding_work.hpp>
28 #include <boost/asio/executor_work_guard.hpp>
29 #include <boost/asio/is_executor.hpp>
30 #include <boost/asio/system_executor.hpp>
31
32 #include <boost/asio/detail/push_options.hpp>
33
34 namespace boost {
35 namespace asio {
36
37 namespace detail
38 {
39 template <typename Executor, typename = void>
40 class composed_work_guard
41 {
42 public:
43 typedef typename decay<
44 typename prefer_result<Executor,
45 execution::outstanding_work_t::tracked_t
46 >::type
47 >::type executor_type;
48
49 composed_work_guard(const Executor& ex)
50 : executor_(boost::asio::prefer(ex, execution::outstanding_work.tracked))
51 {
52 }
53
54 void reset()
55 {
56 }
57
58 executor_type get_executor() const BOOST_ASIO_NOEXCEPT
59 {
60 return executor_;
61 }
62
63 private:
64 executor_type executor_;
65 };
66
67 template <>
68 struct composed_work_guard<system_executor>
69 {
70 public:
71 typedef system_executor executor_type;
72
73 composed_work_guard(const system_executor&)
74 {
75 }
76
77 void reset()
78 {
79 }
80
81 executor_type get_executor() const BOOST_ASIO_NOEXCEPT
82 {
83 return system_executor();
84 }
85 };
86
87 #if !defined(BOOST_ASIO_NO_TS_EXECUTORS)
88
89 template <typename Executor>
90 struct composed_work_guard<Executor,
91 typename enable_if<
92 !execution::is_executor<Executor>::value
93 >::type> : executor_work_guard<Executor>
94 {
95 composed_work_guard(const Executor& ex)
96 : executor_work_guard<Executor>(ex)
97 {
98 }
99 };
100
101 #endif // !defined(BOOST_ASIO_NO_TS_EXECUTORS)
102
103 template <typename>
104 struct composed_io_executors;
105
106 template <>
107 struct composed_io_executors<void()>
108 {
109 composed_io_executors() BOOST_ASIO_NOEXCEPT
110 : head_(system_executor())
111 {
112 }
113
114 typedef system_executor head_type;
115 system_executor head_;
116 };
117
118 inline composed_io_executors<void()> make_composed_io_executors()
119 {
120 return composed_io_executors<void()>();
121 }
122
123 template <typename Head>
124 struct composed_io_executors<void(Head)>
125 {
126 explicit composed_io_executors(const Head& ex) BOOST_ASIO_NOEXCEPT
127 : head_(ex)
128 {
129 }
130
131 typedef Head head_type;
132 Head head_;
133 };
134
135 template <typename Head>
136 inline composed_io_executors<void(Head)>
137 make_composed_io_executors(const Head& head)
138 {
139 return composed_io_executors<void(Head)>(head);
140 }
141
142 #if defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
143
144 template <typename Head, typename... Tail>
145 struct composed_io_executors<void(Head, Tail...)>
146 {
147 explicit composed_io_executors(const Head& head,
148 const Tail&... tail) BOOST_ASIO_NOEXCEPT
149 : head_(head),
150 tail_(tail...)
151 {
152 }
153
154 void reset()
155 {
156 head_.reset();
157 tail_.reset();
158 }
159
160 typedef Head head_type;
161 Head head_;
162 composed_io_executors<void(Tail...)> tail_;
163 };
164
165 template <typename Head, typename... Tail>
166 inline composed_io_executors<void(Head, Tail...)>
167 make_composed_io_executors(const Head& head, const Tail&... tail)
168 {
169 return composed_io_executors<void(Head, Tail...)>(head, tail...);
170 }
171
172 #else // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
173
174 #define BOOST_ASIO_PRIVATE_COMPOSED_IO_EXECUTORS_DEF(n) \
175 template <typename Head, BOOST_ASIO_VARIADIC_TPARAMS(n)> \
176 struct composed_io_executors<void(Head, BOOST_ASIO_VARIADIC_TARGS(n))> \
177 { \
178 explicit composed_io_executors(const Head& head, \
179 BOOST_ASIO_VARIADIC_CONSTREF_PARAMS(n)) BOOST_ASIO_NOEXCEPT \
180 : head_(head), \
181 tail_(BOOST_ASIO_VARIADIC_BYVAL_ARGS(n)) \
182 { \
183 } \
184 \
185 void reset() \
186 { \
187 head_.reset(); \
188 tail_.reset(); \
189 } \
190 \
191 typedef Head head_type; \
192 Head head_; \
193 composed_io_executors<void(BOOST_ASIO_VARIADIC_TARGS(n))> tail_; \
194 }; \
195 \
196 template <typename Head, BOOST_ASIO_VARIADIC_TPARAMS(n)> \
197 inline composed_io_executors<void(Head, BOOST_ASIO_VARIADIC_TARGS(n))> \
198 make_composed_io_executors(const Head& head, \
199 BOOST_ASIO_VARIADIC_CONSTREF_PARAMS(n)) \
200 { \
201 return composed_io_executors< \
202 void(Head, BOOST_ASIO_VARIADIC_TARGS(n))>( \
203 head, BOOST_ASIO_VARIADIC_BYVAL_ARGS(n)); \
204 } \
205 /**/
206 BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_COMPOSED_IO_EXECUTORS_DEF)
207 #undef BOOST_ASIO_PRIVATE_COMPOSED_IO_EXECUTORS_DEF
208
209 #endif // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
210
211 template <typename>
212 struct composed_work;
213
214 template <>
215 struct composed_work<void()>
216 {
217 typedef composed_io_executors<void()> executors_type;
218
219 composed_work(const executors_type&) BOOST_ASIO_NOEXCEPT
220 : head_(system_executor())
221 {
222 }
223
224 void reset()
225 {
226 head_.reset();
227 }
228
229 typedef system_executor head_type;
230 composed_work_guard<system_executor> head_;
231 };
232
233 template <typename Head>
234 struct composed_work<void(Head)>
235 {
236 typedef composed_io_executors<void(Head)> executors_type;
237
238 explicit composed_work(const executors_type& ex) BOOST_ASIO_NOEXCEPT
239 : head_(ex.head_)
240 {
241 }
242
243 void reset()
244 {
245 head_.reset();
246 }
247
248 typedef Head head_type;
249 composed_work_guard<Head> head_;
250 };
251
252 #if defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
253
254 template <typename Head, typename... Tail>
255 struct composed_work<void(Head, Tail...)>
256 {
257 typedef composed_io_executors<void(Head, Tail...)> executors_type;
258
259 explicit composed_work(const executors_type& ex) BOOST_ASIO_NOEXCEPT
260 : head_(ex.head_),
261 tail_(ex.tail_)
262 {
263 }
264
265 void reset()
266 {
267 head_.reset();
268 tail_.reset();
269 }
270
271 typedef Head head_type;
272 composed_work_guard<Head> head_;
273 composed_work<void(Tail...)> tail_;
274 };
275
276 #else // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
277
278 #define BOOST_ASIO_PRIVATE_COMPOSED_WORK_DEF(n) \
279 template <typename Head, BOOST_ASIO_VARIADIC_TPARAMS(n)> \
280 struct composed_work<void(Head, BOOST_ASIO_VARIADIC_TARGS(n))> \
281 { \
282 typedef composed_io_executors<void(Head, \
283 BOOST_ASIO_VARIADIC_TARGS(n))> executors_type; \
284 \
285 explicit composed_work(const executors_type& ex) BOOST_ASIO_NOEXCEPT \
286 : head_(ex.head_), \
287 tail_(ex.tail_) \
288 { \
289 } \
290 \
291 void reset() \
292 { \
293 head_.reset(); \
294 tail_.reset(); \
295 } \
296 \
297 typedef Head head_type; \
298 composed_work_guard<Head> head_; \
299 composed_work<void(BOOST_ASIO_VARIADIC_TARGS(n))> tail_; \
300 }; \
301 /**/
302 BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_COMPOSED_WORK_DEF)
303 #undef BOOST_ASIO_PRIVATE_COMPOSED_WORK_DEF
304
305 #endif // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
306
307 #if defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
308 template <typename Impl, typename Work, typename Handler, typename Signature>
309 class composed_op;
310
311 template <typename Impl, typename Work, typename Handler,
312 typename R, typename... Args>
313 class composed_op<Impl, Work, Handler, R(Args...)>
314 #else // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
315 template <typename Impl, typename Work, typename Handler, typename Signature>
316 class composed_op
317 #endif // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
318 : public base_from_cancellation_state<Handler>
319 {
320 public:
321 template <typename I, typename W, typename H>
322 composed_op(BOOST_ASIO_MOVE_ARG(I) impl,
323 BOOST_ASIO_MOVE_ARG(W) work,
324 BOOST_ASIO_MOVE_ARG(H) handler)
325 : base_from_cancellation_state<Handler>(
326 handler, enable_terminal_cancellation()),
327 impl_(BOOST_ASIO_MOVE_CAST(I)(impl)),
328 work_(BOOST_ASIO_MOVE_CAST(W)(work)),
329 handler_(BOOST_ASIO_MOVE_CAST(H)(handler)),
330 invocations_(0)
331 {
332 }
333
334 #if defined(BOOST_ASIO_HAS_MOVE)
335 composed_op(composed_op&& other)
336 : base_from_cancellation_state<Handler>(
337 BOOST_ASIO_MOVE_CAST(base_from_cancellation_state<
338 Handler>)(other)),
339 impl_(BOOST_ASIO_MOVE_CAST(Impl)(other.impl_)),
340 work_(BOOST_ASIO_MOVE_CAST(Work)(other.work_)),
341 handler_(BOOST_ASIO_MOVE_CAST(Handler)(other.handler_)),
342 invocations_(other.invocations_)
343 {
344 }
345 #endif // defined(BOOST_ASIO_HAS_MOVE)
346
347 typedef typename associated_executor<Handler,
348 typename composed_work_guard<
349 typename Work::head_type
350 >::executor_type
351 >::type executor_type;
352
353 executor_type get_executor() const BOOST_ASIO_NOEXCEPT
354 {
355 return (get_associated_executor)(handler_, work_.head_.get_executor());
356 }
357
358 typedef typename associated_allocator<Handler,
359 std::allocator<void> >::type allocator_type;
360
361 allocator_type get_allocator() const BOOST_ASIO_NOEXCEPT
362 {
363 return (get_associated_allocator)(handler_, std::allocator<void>());
364 }
365
366 #if defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
367
368 template<typename... T>
369 void operator()(BOOST_ASIO_MOVE_ARG(T)... t)
370 {
371 if (invocations_ < ~0u)
372 ++invocations_;
373 this->get_cancellation_state().slot().clear();
374 impl_(*this, BOOST_ASIO_MOVE_CAST(T)(t)...);
375 }
376
377 void complete(Args... args)
378 {
379 this->work_.reset();
380 BOOST_ASIO_MOVE_OR_LVALUE(Handler)(this->handler_)(
381 BOOST_ASIO_MOVE_CAST(Args)(args)...);
382 }
383
384 #else // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
385
386 void operator()()
387 {
388 if (invocations_ < ~0u)
389 ++invocations_;
390 this->get_cancellation_state().slot().clear();
391 impl_(*this);
392 }
393
394 void complete()
395 {
396 this->work_.reset();
397 BOOST_ASIO_MOVE_OR_LVALUE(Handler)(this->handler_)();
398 }
399
400 #define BOOST_ASIO_PRIVATE_COMPOSED_OP_DEF(n) \
401 template<BOOST_ASIO_VARIADIC_TPARAMS(n)> \
402 void operator()(BOOST_ASIO_VARIADIC_MOVE_PARAMS(n)) \
403 { \
404 if (invocations_ < ~0u) \
405 ++invocations_; \
406 this->get_cancellation_state().slot().clear(); \
407 impl_(*this, BOOST_ASIO_VARIADIC_MOVE_ARGS(n)); \
408 } \
409 \
410 template<BOOST_ASIO_VARIADIC_TPARAMS(n)> \
411 void complete(BOOST_ASIO_VARIADIC_MOVE_PARAMS(n)) \
412 { \
413 this->work_.reset(); \
414 BOOST_ASIO_MOVE_OR_LVALUE(Handler)(this->handler_)( \
415 BOOST_ASIO_VARIADIC_MOVE_ARGS(n)); \
416 } \
417 /**/
418 BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_COMPOSED_OP_DEF)
419 #undef BOOST_ASIO_PRIVATE_COMPOSED_OP_DEF
420
421 #endif // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
422
423 void reset_cancellation_state()
424 {
425 base_from_cancellation_state<Handler>::reset_cancellation_state(handler_);
426 }
427
428 template <typename Filter>
429 void reset_cancellation_state(BOOST_ASIO_MOVE_ARG(Filter) filter)
430 {
431 base_from_cancellation_state<Handler>::reset_cancellation_state(handler_,
432 BOOST_ASIO_MOVE_CAST(Filter)(filter));
433 }
434
435 template <typename InFilter, typename OutFilter>
436 void reset_cancellation_state(BOOST_ASIO_MOVE_ARG(InFilter) in_filter,
437 BOOST_ASIO_MOVE_ARG(OutFilter) out_filter)
438 {
439 base_from_cancellation_state<Handler>::reset_cancellation_state(handler_,
440 BOOST_ASIO_MOVE_CAST(InFilter)(in_filter),
441 BOOST_ASIO_MOVE_CAST(OutFilter)(out_filter));
442 }
443
444 //private:
445 Impl impl_;
446 Work work_;
447 Handler handler_;
448 unsigned invocations_;
449 };
450
451 template <typename Impl, typename Work, typename Handler, typename Signature>
452 inline asio_handler_allocate_is_deprecated
453 asio_handler_allocate(std::size_t size,
454 composed_op<Impl, Work, Handler, Signature>* this_handler)
455 {
456 #if defined(BOOST_ASIO_NO_DEPRECATED)
457 boost_asio_handler_alloc_helpers::allocate(size, this_handler->handler_);
458 return asio_handler_allocate_is_no_longer_used();
459 #else // defined(BOOST_ASIO_NO_DEPRECATED)
460 return boost_asio_handler_alloc_helpers::allocate(
461 size, this_handler->handler_);
462 #endif // defined(BOOST_ASIO_NO_DEPRECATED)
463 }
464
465 template <typename Impl, typename Work, typename Handler, typename Signature>
466 inline asio_handler_deallocate_is_deprecated
467 asio_handler_deallocate(void* pointer, std::size_t size,
468 composed_op<Impl, Work, Handler, Signature>* this_handler)
469 {
470 boost_asio_handler_alloc_helpers::deallocate(
471 pointer, size, this_handler->handler_);
472 #if defined(BOOST_ASIO_NO_DEPRECATED)
473 return asio_handler_deallocate_is_no_longer_used();
474 #endif // defined(BOOST_ASIO_NO_DEPRECATED)
475 }
476
477 template <typename Impl, typename Work, typename Handler, typename Signature>
478 inline bool asio_handler_is_continuation(
479 composed_op<Impl, Work, Handler, Signature>* this_handler)
480 {
481 return this_handler->invocations_ > 1 ? true
482 : boost_asio_handler_cont_helpers::is_continuation(
483 this_handler->handler_);
484 }
485
486 template <typename Function, typename Impl,
487 typename Work, typename Handler, typename Signature>
488 inline asio_handler_invoke_is_deprecated
489 asio_handler_invoke(Function& function,
490 composed_op<Impl, Work, Handler, Signature>* this_handler)
491 {
492 boost_asio_handler_invoke_helpers::invoke(
493 function, this_handler->handler_);
494 #if defined(BOOST_ASIO_NO_DEPRECATED)
495 return asio_handler_invoke_is_no_longer_used();
496 #endif // defined(BOOST_ASIO_NO_DEPRECATED)
497 }
498
499 template <typename Function, typename Impl,
500 typename Work, typename Handler, typename Signature>
501 inline asio_handler_invoke_is_deprecated
502 asio_handler_invoke(const Function& function,
503 composed_op<Impl, Work, Handler, Signature>* this_handler)
504 {
505 boost_asio_handler_invoke_helpers::invoke(
506 function, this_handler->handler_);
507 #if defined(BOOST_ASIO_NO_DEPRECATED)
508 return asio_handler_invoke_is_no_longer_used();
509 #endif // defined(BOOST_ASIO_NO_DEPRECATED)
510 }
511
512 template <typename Signature, typename Executors>
513 class initiate_composed_op
514 {
515 public:
516 typedef typename composed_io_executors<Executors>::head_type executor_type;
517
518 template <typename T>
519 explicit initiate_composed_op(int, BOOST_ASIO_MOVE_ARG(T) executors)
520 : executors_(BOOST_ASIO_MOVE_CAST(T)(executors))
521 {
522 }
523
524 executor_type get_executor() const BOOST_ASIO_NOEXCEPT
525 {
526 return executors_.head_;
527 }
528
529 template <typename Handler, typename Impl>
530 void operator()(BOOST_ASIO_MOVE_ARG(Handler) handler,
531 BOOST_ASIO_MOVE_ARG(Impl) impl) const
532 {
533 composed_op<typename decay<Impl>::type, composed_work<Executors>,
534 typename decay<Handler>::type, Signature>(
535 BOOST_ASIO_MOVE_CAST(Impl)(impl),
536 composed_work<Executors>(executors_),
537 BOOST_ASIO_MOVE_CAST(Handler)(handler))();
538 }
539
540 private:
541 composed_io_executors<Executors> executors_;
542 };
543
544 template <typename Signature, typename Executors>
545 inline initiate_composed_op<Signature, Executors> make_initiate_composed_op(
546 BOOST_ASIO_MOVE_ARG(composed_io_executors<Executors>) executors)
547 {
548 return initiate_composed_op<Signature, Executors>(0,
549 BOOST_ASIO_MOVE_CAST(composed_io_executors<Executors>)(executors));
550 }
551
552 template <typename IoObject>
553 inline typename IoObject::executor_type
554 get_composed_io_executor(IoObject& io_object,
555 typename enable_if<
556 !is_executor<IoObject>::value
557 >::type* = 0,
558 typename enable_if<
559 !execution::is_executor<IoObject>::value
560 >::type* = 0)
561 {
562 return io_object.get_executor();
563 }
564
565 template <typename Executor>
566 inline const Executor& get_composed_io_executor(const Executor& ex,
567 typename enable_if<
568 is_executor<Executor>::value
569 || execution::is_executor<Executor>::value
570 >::type* = 0)
571 {
572 return ex;
573 }
574 } // namespace detail
575
576 #if !defined(GENERATING_DOCUMENTATION)
577
578 template <template <typename, typename> class Associator,
579 typename Impl, typename Work, typename Handler,
580 typename Signature, typename DefaultCandidate>
581 struct associator<Associator,
582 detail::composed_op<Impl, Work, Handler, Signature>,
583 DefaultCandidate>
584 : Associator<Handler, DefaultCandidate>
585 {
586 static typename Associator<Handler, DefaultCandidate>::type get(
587 const detail::composed_op<Impl, Work, Handler, Signature>& h,
588 const DefaultCandidate& c = DefaultCandidate()) BOOST_ASIO_NOEXCEPT
589 {
590 return Associator<Handler, DefaultCandidate>::get(h.handler_, c);
591 }
592 };
593
594 #if defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
595
596 template <typename CompletionToken, typename Signature,
597 typename Implementation, typename... IoObjectsOrExecutors>
598 BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, Signature)
599 async_compose(BOOST_ASIO_MOVE_ARG(Implementation) implementation,
600 BOOST_ASIO_NONDEDUCED_MOVE_ARG(CompletionToken) token,
601 BOOST_ASIO_MOVE_ARG(IoObjectsOrExecutors)... io_objects_or_executors)
602 {
603 return async_initiate<CompletionToken, Signature>(
604 detail::make_initiate_composed_op<Signature>(
605 detail::make_composed_io_executors(
606 detail::get_composed_io_executor(
607 BOOST_ASIO_MOVE_CAST(IoObjectsOrExecutors)(
608 io_objects_or_executors))...)),
609 token, BOOST_ASIO_MOVE_CAST(Implementation)(implementation));
610 }
611
612 #else // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
613
614 template <typename CompletionToken, typename Signature, typename Implementation>
615 BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, Signature)
616 async_compose(BOOST_ASIO_MOVE_ARG(Implementation) implementation,
617 BOOST_ASIO_NONDEDUCED_MOVE_ARG(CompletionToken) token)
618 {
619 return async_initiate<CompletionToken, Signature>(
620 detail::make_initiate_composed_op<Signature>(
621 detail::make_composed_io_executors()),
622 token, BOOST_ASIO_MOVE_CAST(Implementation)(implementation));
623 }
624
625 # define BOOST_ASIO_PRIVATE_GET_COMPOSED_IO_EXECUTOR(n) \
626 BOOST_ASIO_PRIVATE_GET_COMPOSED_IO_EXECUTOR_##n
627
628 # define BOOST_ASIO_PRIVATE_GET_COMPOSED_IO_EXECUTOR_1 \
629 detail::get_composed_io_executor(BOOST_ASIO_MOVE_CAST(T1)(x1))
630 # define BOOST_ASIO_PRIVATE_GET_COMPOSED_IO_EXECUTOR_2 \
631 detail::get_composed_io_executor(BOOST_ASIO_MOVE_CAST(T1)(x1)), \
632 detail::get_composed_io_executor(BOOST_ASIO_MOVE_CAST(T2)(x2))
633 # define BOOST_ASIO_PRIVATE_GET_COMPOSED_IO_EXECUTOR_3 \
634 detail::get_composed_io_executor(BOOST_ASIO_MOVE_CAST(T1)(x1)), \
635 detail::get_composed_io_executor(BOOST_ASIO_MOVE_CAST(T2)(x2)), \
636 detail::get_composed_io_executor(BOOST_ASIO_MOVE_CAST(T3)(x3))
637 # define BOOST_ASIO_PRIVATE_GET_COMPOSED_IO_EXECUTOR_4 \
638 detail::get_composed_io_executor(BOOST_ASIO_MOVE_CAST(T1)(x1)), \
639 detail::get_composed_io_executor(BOOST_ASIO_MOVE_CAST(T2)(x2)), \
640 detail::get_composed_io_executor(BOOST_ASIO_MOVE_CAST(T3)(x3)), \
641 detail::get_composed_io_executor(BOOST_ASIO_MOVE_CAST(T4)(x4))
642 # define BOOST_ASIO_PRIVATE_GET_COMPOSED_IO_EXECUTOR_5 \
643 detail::get_composed_io_executor(BOOST_ASIO_MOVE_CAST(T1)(x1)), \
644 detail::get_composed_io_executor(BOOST_ASIO_MOVE_CAST(T2)(x2)), \
645 detail::get_composed_io_executor(BOOST_ASIO_MOVE_CAST(T3)(x3)), \
646 detail::get_composed_io_executor(BOOST_ASIO_MOVE_CAST(T4)(x4)), \
647 detail::get_composed_io_executor(BOOST_ASIO_MOVE_CAST(T5)(x5))
648 # define BOOST_ASIO_PRIVATE_GET_COMPOSED_IO_EXECUTOR_6 \
649 detail::get_composed_io_executor(BOOST_ASIO_MOVE_CAST(T1)(x1)), \
650 detail::get_composed_io_executor(BOOST_ASIO_MOVE_CAST(T2)(x2)), \
651 detail::get_composed_io_executor(BOOST_ASIO_MOVE_CAST(T3)(x3)), \
652 detail::get_composed_io_executor(BOOST_ASIO_MOVE_CAST(T4)(x4)), \
653 detail::get_composed_io_executor(BOOST_ASIO_MOVE_CAST(T5)(x5)), \
654 detail::get_composed_io_executor(BOOST_ASIO_MOVE_CAST(T6)(x6))
655 # define BOOST_ASIO_PRIVATE_GET_COMPOSED_IO_EXECUTOR_7 \
656 detail::get_composed_io_executor(BOOST_ASIO_MOVE_CAST(T1)(x1)), \
657 detail::get_composed_io_executor(BOOST_ASIO_MOVE_CAST(T2)(x2)), \
658 detail::get_composed_io_executor(BOOST_ASIO_MOVE_CAST(T3)(x3)), \
659 detail::get_composed_io_executor(BOOST_ASIO_MOVE_CAST(T4)(x4)), \
660 detail::get_composed_io_executor(BOOST_ASIO_MOVE_CAST(T5)(x5)), \
661 detail::get_composed_io_executor(BOOST_ASIO_MOVE_CAST(T6)(x6)), \
662 detail::get_composed_io_executor(BOOST_ASIO_MOVE_CAST(T7)(x7))
663 # define BOOST_ASIO_PRIVATE_GET_COMPOSED_IO_EXECUTOR_8 \
664 detail::get_composed_io_executor(BOOST_ASIO_MOVE_CAST(T1)(x1)), \
665 detail::get_composed_io_executor(BOOST_ASIO_MOVE_CAST(T2)(x2)), \
666 detail::get_composed_io_executor(BOOST_ASIO_MOVE_CAST(T3)(x3)), \
667 detail::get_composed_io_executor(BOOST_ASIO_MOVE_CAST(T4)(x4)), \
668 detail::get_composed_io_executor(BOOST_ASIO_MOVE_CAST(T5)(x5)), \
669 detail::get_composed_io_executor(BOOST_ASIO_MOVE_CAST(T6)(x6)), \
670 detail::get_composed_io_executor(BOOST_ASIO_MOVE_CAST(T7)(x7)), \
671 detail::get_composed_io_executor(BOOST_ASIO_MOVE_CAST(T8)(x8))
672
673 #define BOOST_ASIO_PRIVATE_ASYNC_COMPOSE_DEF(n) \
674 template <typename CompletionToken, typename Signature, \
675 typename Implementation, BOOST_ASIO_VARIADIC_TPARAMS(n)> \
676 BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, Signature) \
677 async_compose(BOOST_ASIO_MOVE_ARG(Implementation) implementation, \
678 BOOST_ASIO_NONDEDUCED_MOVE_ARG(CompletionToken) token, \
679 BOOST_ASIO_VARIADIC_MOVE_PARAMS(n)) \
680 { \
681 return async_initiate<CompletionToken, Signature>( \
682 detail::make_initiate_composed_op<Signature>( \
683 detail::make_composed_io_executors( \
684 BOOST_ASIO_PRIVATE_GET_COMPOSED_IO_EXECUTOR(n))), \
685 token, BOOST_ASIO_MOVE_CAST(Implementation)(implementation)); \
686 } \
687 /**/
688 BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_ASYNC_COMPOSE_DEF)
689 #undef BOOST_ASIO_PRIVATE_ASYNC_COMPOSE_DEF
690
691 #undef BOOST_ASIO_PRIVATE_GET_COMPOSED_IO_EXECUTOR
692 #undef BOOST_ASIO_PRIVATE_GET_COMPOSED_IO_EXECUTOR_1
693 #undef BOOST_ASIO_PRIVATE_GET_COMPOSED_IO_EXECUTOR_2
694 #undef BOOST_ASIO_PRIVATE_GET_COMPOSED_IO_EXECUTOR_3
695 #undef BOOST_ASIO_PRIVATE_GET_COMPOSED_IO_EXECUTOR_4
696 #undef BOOST_ASIO_PRIVATE_GET_COMPOSED_IO_EXECUTOR_5
697 #undef BOOST_ASIO_PRIVATE_GET_COMPOSED_IO_EXECUTOR_6
698 #undef BOOST_ASIO_PRIVATE_GET_COMPOSED_IO_EXECUTOR_7
699 #undef BOOST_ASIO_PRIVATE_GET_COMPOSED_IO_EXECUTOR_8
700
701 #endif // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
702 #endif // !defined(GENERATING_DOCUMENTATION)
703
704 } // namespace asio
705 } // namespace boost
706
707 #include <boost/asio/detail/pop_options.hpp>
708
709 #endif // BOOST_ASIO_IMPL_COMPOSE_HPP