Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:29:24

0001 //
0002 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
0003 //
0004 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0005 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 //
0007 // Official repository: https://github.com/boostorg/beast
0008 //
0009 
0010 #ifndef BOOST_BEAST_DETAIL_BIND_CONTINUATION_HPP
0011 #define BOOST_BEAST_DETAIL_BIND_CONTINUATION_HPP
0012 
0013 #include <boost/beast/core/detail/config.hpp>
0014 #include <boost/beast/core/detail/remap_post_to_defer.hpp>
0015 #include <boost/asio/bind_executor.hpp>
0016 #include <boost/core/empty_value.hpp>
0017 #include <type_traits>
0018 #include <utility>
0019 
0020 namespace boost {
0021 namespace beast {
0022 namespace detail {
0023 
0024 #if 0
0025 /** Mark a completion handler as a continuation.
0026 
0027     This function wraps a completion handler to associate it with an
0028     executor whose `post` operation is remapped to the `defer` operation.
0029     It is used by composed asynchronous operation implementations to
0030     indicate that a completion handler submitted to an initiating
0031     function represents a continuation of the current asynchronous
0032     flow of control.
0033 
0034     @param handler The handler to wrap.
0035     The implementation takes ownership of the handler by performing a decay-copy.
0036 
0037     @see
0038 
0039     @li <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4242.html">[N4242] Executors and Asynchronous Operations, Revision 1</a>
0040 */
0041 template<class CompletionHandler>
0042 #if BOOST_BEAST_DOXYGEN
0043 __implementation_defined__
0044 #else
0045 net::executor_binder<
0046     typename std::decay<CompletionHandler>::type,
0047     detail::remap_post_to_defer<
0048         net::associated_executor_t<CompletionHandler>>>
0049 #endif
0050 bind_continuation(CompletionHandler&& handler)
0051 {
0052     return net::bind_executor(
0053         detail::remap_post_to_defer<
0054             net::associated_executor_t<CompletionHandler>>(
0055                 net::get_associated_executor(handler)),
0056         std::forward<CompletionHandler>(handler));
0057 }
0058 
0059 /** Mark a completion handler as a continuation.
0060 
0061     This function wraps a completion handler to associate it with an
0062     executor whose `post` operation is remapped to the `defer` operation.
0063     It is used by composed asynchronous operation implementations to
0064     indicate that a completion handler submitted to an initiating
0065     function represents a continuation of the current asynchronous
0066     flow of control.
0067 
0068     @param ex The executor to use
0069 
0070     @param handler The handler to wrap
0071     The implementation takes ownership of the handler by performing a decay-copy.
0072 
0073     @see
0074 
0075     @li <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4242.html">[N4242] Executors and Asynchronous Operations, Revision 1</a>
0076 */
0077 template<class Executor, class CompletionHandler>
0078 #if BOOST_BEAST_DOXYGEN
0079 __implementation_defined__
0080 #else
0081 net::executor_binder<typename
0082     std::decay<CompletionHandler>::type,
0083     detail::remap_post_to_defer<Executor>>
0084 #endif
0085 bind_continuation(
0086     Executor const& ex, CompletionHandler&& handler)
0087 {
0088     return net::bind_executor(
0089         detail::remap_post_to_defer<Executor>(ex),
0090         std::forward<CompletionHandler>(handler));
0091 }
0092 #else
0093 // VFALCO I turned these off at the last minute because they cause
0094 //        the completion handler to be moved before the initiating
0095 //        function is invoked rather than after, which is a foot-gun.
0096 //
0097 // REMINDER: Uncomment the tests when this is put back
0098 template<class F>
0099 F&&
0100 bind_continuation(F&& f)
0101 {
0102     return std::forward<F>(f);
0103 }
0104 #endif
0105 
0106 } // detail
0107 } // beast
0108 } // boost
0109 
0110 #endif