// // deprecated_async_ops.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~ // // Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #ifndef ARCHETYPES_DEPRECATED_ASYNC_OPS_HPP #define ARCHETYPES_DEPRECATED_ASYNC_OPS_HPP #include #if !defined(BOOST_ASIO_NO_DEPRECATED) #include #include #include #if defined(BOOST_ASIO_HAS_BOOST_BIND) # include #else // defined(BOOST_ASIO_HAS_BOOST_BIND) # include #endif // defined(BOOST_ASIO_HAS_BOOST_BIND) namespace archetypes { #if defined(BOOST_ASIO_HAS_BOOST_BIND) namespace bindns = boost; #else // defined(BOOST_ASIO_HAS_BOOST_BIND) namespace bindns = std; #endif // defined(BOOST_ASIO_HAS_BOOST_BIND) template typename boost::asio::async_result< typename boost::asio::handler_type::type>::type deprecated_async_op_0(boost::asio::io_context& ctx, BOOST_ASIO_MOVE_ARG(CompletionToken) token) { typedef typename boost::asio::handler_type::type handler_type; handler_type handler(BOOST_ASIO_MOVE_CAST(CompletionToken)(token)); boost::asio::async_result result(handler); ctx.post(bindns::bind(BOOST_ASIO_MOVE_CAST(handler_type)(handler))); return result.get(); } template typename boost::asio::async_result< typename boost::asio::handler_type::type>::type deprecated_async_op_ec_0(boost::asio::io_context& ctx, bool ok, BOOST_ASIO_MOVE_ARG(CompletionToken) token) { typedef typename boost::asio::handler_type::type handler_type; handler_type handler(BOOST_ASIO_MOVE_CAST(CompletionToken)(token)); boost::asio::async_result result(handler); if (ok) { ctx.post(bindns::bind(BOOST_ASIO_MOVE_CAST(handler_type)(handler), boost::system::error_code())); } else { ctx.post(bindns::bind(BOOST_ASIO_MOVE_CAST(handler_type)(handler), boost::system::error_code(boost::asio::error::operation_aborted))); } return result.get(); } template typename boost::asio::async_result< typename boost::asio::handler_type::type>::type deprecated_async_op_ex_0(boost::asio::io_context& ctx, bool ok, BOOST_ASIO_MOVE_ARG(CompletionToken) token) { typedef typename boost::asio::handler_type::type handler_type; handler_type handler(BOOST_ASIO_MOVE_CAST(CompletionToken)(token)); boost::asio::async_result result(handler); if (ok) { ctx.post(bindns::bind(BOOST_ASIO_MOVE_CAST(handler_type)(handler), std::exception_ptr())); } else { ctx.post(bindns::bind(BOOST_ASIO_MOVE_CAST(handler_type)(handler), std::make_exception_ptr(std::runtime_error("blah")))); } return result.get(); } template typename boost::asio::async_result< typename boost::asio::handler_type::type>::type deprecated_async_op_1(boost::asio::io_context& ctx, BOOST_ASIO_MOVE_ARG(CompletionToken) token) { typedef typename boost::asio::handler_type::type handler_type; handler_type handler(BOOST_ASIO_MOVE_CAST(CompletionToken)(token)); boost::asio::async_result result(handler); ctx.post(bindns::bind(BOOST_ASIO_MOVE_CAST(handler_type)(handler), 42)); return result.get(); } template typename boost::asio::async_result< typename boost::asio::handler_type::type>::type deprecated_async_op_ec_1(boost::asio::io_context& ctx, bool ok, BOOST_ASIO_MOVE_ARG(CompletionToken) token) { typedef typename boost::asio::handler_type::type handler_type; handler_type handler(BOOST_ASIO_MOVE_CAST(CompletionToken)(token)); boost::asio::async_result result(handler); if (ok) { ctx.post(bindns::bind(BOOST_ASIO_MOVE_CAST(handler_type)(handler), boost::system::error_code(), 42)); } else { ctx.post(bindns::bind(BOOST_ASIO_MOVE_CAST(handler_type)(handler), boost::system::error_code(boost::asio::error::operation_aborted), 0)); } return result.get(); } template typename boost::asio::async_result< typename boost::asio::handler_type::type>::type deprecated_async_op_ex_1(boost::asio::io_context& ctx, bool ok, BOOST_ASIO_MOVE_ARG(CompletionToken) token) { typedef typename boost::asio::handler_type::type handler_type; handler_type handler(BOOST_ASIO_MOVE_CAST(CompletionToken)(token)); boost::asio::async_result result(handler); if (ok) { ctx.post(bindns::bind(BOOST_ASIO_MOVE_CAST(handler_type)(handler), std::exception_ptr(), 42)); } else { ctx.post(bindns::bind(BOOST_ASIO_MOVE_CAST(handler_type)(handler), std::make_exception_ptr(std::runtime_error("blah")), 0)); } return result.get(); } template typename boost::asio::async_result< typename boost::asio::handler_type::type>::type deprecated_async_op_2(boost::asio::io_context& ctx, BOOST_ASIO_MOVE_ARG(CompletionToken) token) { typedef typename boost::asio::handler_type::type handler_type; handler_type handler(BOOST_ASIO_MOVE_CAST(CompletionToken)(token)); boost::asio::async_result result(handler); ctx.post(bindns::bind(BOOST_ASIO_MOVE_CAST(handler_type)(handler), 42, 2.0)); return result.get(); } template typename boost::asio::async_result< typename boost::asio::handler_type::type>::type deprecated_async_op_ec_2(boost::asio::io_context& ctx, bool ok, BOOST_ASIO_MOVE_ARG(CompletionToken) token) { typedef typename boost::asio::handler_type::type handler_type; handler_type handler(BOOST_ASIO_MOVE_CAST(CompletionToken)(token)); boost::asio::async_result result(handler); if (ok) { ctx.post(bindns::bind(BOOST_ASIO_MOVE_CAST(handler_type)(handler), boost::system::error_code(), 42, 2.0)); } else { ctx.post(bindns::bind(BOOST_ASIO_MOVE_CAST(handler_type)(handler), boost::system::error_code(boost::asio::error::operation_aborted), 0, 0.0)); } return result.get(); } template typename boost::asio::async_result< typename boost::asio::handler_type::type>::type deprecated_async_op_ex_2(boost::asio::io_context& ctx, bool ok, BOOST_ASIO_MOVE_ARG(CompletionToken) token) { typedef typename boost::asio::handler_type::type handler_type; handler_type handler(BOOST_ASIO_MOVE_CAST(CompletionToken)(token)); boost::asio::async_result result(handler); if (ok) { ctx.post(bindns::bind(BOOST_ASIO_MOVE_CAST(handler_type)(handler), std::exception_ptr(), 42, 2.0)); } else { ctx.post(bindns::bind(BOOST_ASIO_MOVE_CAST(handler_type)(handler), std::make_exception_ptr(std::runtime_error("blah")), 0, 0.0)); } return result.get(); } template typename boost::asio::async_result< typename boost::asio::handler_type::type>::type deprecated_async_op_3(boost::asio::io_context& ctx, BOOST_ASIO_MOVE_ARG(CompletionToken) token) { typedef typename boost::asio::handler_type::type handler_type; handler_type handler(BOOST_ASIO_MOVE_CAST(CompletionToken)(token)); boost::asio::async_result result(handler); ctx.post(bindns::bind(BOOST_ASIO_MOVE_CAST(handler_type)(handler), 42, 2.0, 'a')); return result.get(); } template typename boost::asio::async_result< typename boost::asio::handler_type::type>::type deprecated_async_op_ec_3(boost::asio::io_context& ctx, bool ok, BOOST_ASIO_MOVE_ARG(CompletionToken) token) { typedef typename boost::asio::handler_type::type handler_type; handler_type handler(BOOST_ASIO_MOVE_CAST(CompletionToken)(token)); boost::asio::async_result result(handler); if (ok) { ctx.post(bindns::bind(BOOST_ASIO_MOVE_CAST(handler_type)(handler), boost::system::error_code(), 42, 2.0, 'a')); } else { ctx.post(bindns::bind(BOOST_ASIO_MOVE_CAST(handler_type)(handler), boost::system::error_code(boost::asio::error::operation_aborted), 0, 0.0, 'z')); } return result.get(); } template typename boost::asio::async_result< typename boost::asio::handler_type::type>::type deprecated_async_op_ex_3(boost::asio::io_context& ctx, bool ok, BOOST_ASIO_MOVE_ARG(CompletionToken) token) { typedef typename boost::asio::handler_type::type handler_type; handler_type handler(BOOST_ASIO_MOVE_CAST(CompletionToken)(token)); boost::asio::async_result result(handler); if (ok) { ctx.post(bindns::bind(BOOST_ASIO_MOVE_CAST(handler_type)(handler), std::exception_ptr(), 42, 2.0, 'a')); } else { ctx.post(bindns::bind(BOOST_ASIO_MOVE_CAST(handler_type)(handler), std::make_exception_ptr(std::runtime_error("blah")), 0, 0.0, 'z')); } return result.get(); } } // namespace archetypes #endif // !defined(BOOST_ASIO_NO_DEPRECATED) #endif // ARCHETYPES_DEPRECATED_ASYNC_OPS_HPP