From 7a46efd8bfc145c06180487c4b856d910c04ca56 Mon Sep 17 00:00:00 2001 From: Christopher Kohlhoff Date: Tue, 16 Aug 2016 09:18:55 +1000 Subject: [PATCH] New async_result with two template parameters. This change makes async_result consistent with the networking TS. The older single-parameter form of async_result, and the handler_type trait, have been deprecated. They have been retained for backwards compatibility, and existing specialisations of these traits will still be used. However, asynchronous operations that use the older form of async_result/handler_type will not interoperate with completion tokens that specialize only the new two-parameter async_result. For this reason, the completion token types implemented by asio continue to provide specialisations of the older form of async_result and handler_type. --- asio/include/asio/async_result.hpp | 162 ++++++++++++++---- asio/include/asio/basic_datagram_socket.hpp | 16 +- asio/include/asio/basic_deadline_timer.hpp | 3 +- asio/include/asio/basic_raw_socket.hpp | 16 +- asio/include/asio/basic_seq_packet_socket.hpp | 6 +- asio/include/asio/basic_socket.hpp | 7 +- asio/include/asio/basic_socket_acceptor.hpp | 16 +- asio/include/asio/basic_stream_socket.hpp | 12 +- asio/include/asio/basic_waitable_timer.hpp | 3 +- asio/include/asio/bind_executor.hpp | 32 +++- asio/include/asio/buffered_read_stream.hpp | 3 +- asio/include/asio/buffered_write_stream.hpp | 3 +- asio/include/asio/datagram_socket_service.hpp | 12 +- asio/include/asio/deadline_timer_service.hpp | 2 +- .../asio/detail/handler_type_requirements.hpp | 2 +- asio/include/asio/handler_type.hpp | 6 +- .../asio/impl/buffered_read_stream.hpp | 6 +- .../asio/impl/buffered_write_stream.hpp | 6 +- asio/include/asio/impl/connect.hpp | 18 +- asio/include/asio/impl/defer.hpp | 24 +-- asio/include/asio/impl/dispatch.hpp | 25 +-- asio/include/asio/impl/io_context.hpp | 17 +- asio/include/asio/impl/post.hpp | 24 +-- asio/include/asio/impl/read.hpp | 6 +- asio/include/asio/impl/read_at.hpp | 8 +- asio/include/asio/impl/read_until.hpp | 9 +- asio/include/asio/impl/spawn.hpp | 1 - asio/include/asio/impl/use_future.hpp | 1 - asio/include/asio/impl/write.hpp | 6 +- asio/include/asio/impl/write_at.hpp | 8 +- asio/include/asio/io_context_strand.hpp | 4 +- asio/include/asio/ip/basic_resolver.hpp | 8 +- asio/include/asio/ip/resolver_service.hpp | 4 +- asio/include/asio/package.hpp | 1 - asio/include/asio/posix/descriptor.hpp | 2 +- asio/include/asio/posix/stream_descriptor.hpp | 4 +- .../asio/posix/stream_descriptor_service.hpp | 6 +- asio/include/asio/raw_socket_service.hpp | 12 +- .../asio/seq_packet_socket_service.hpp | 8 +- asio/include/asio/serial_port.hpp | 4 +- asio/include/asio/serial_port_service.hpp | 4 +- asio/include/asio/signal_set.hpp | 3 +- asio/include/asio/signal_set_service.hpp | 2 +- asio/include/asio/socket_acceptor_service.hpp | 7 +- asio/include/asio/stream_socket_service.hpp | 8 +- asio/include/asio/waitable_timer_service.hpp | 2 +- asio/include/asio/windows/object_handle.hpp | 3 +- .../asio/windows/object_handle_service.hpp | 2 +- .../asio/windows/random_access_handle.hpp | 4 +- .../windows/random_access_handle_service.hpp | 6 +- asio/include/asio/windows/stream_handle.hpp | 4 +- .../asio/windows/stream_handle_service.hpp | 4 +- asio/src/tests/Makefile.am | 1 + .../tests/unit/archetypes/async_result.hpp | 23 +-- .../archetypes/deprecated_async_result.hpp | 82 +++++++++ asio/src/tests/unit/ip/icmp.cpp | 123 ++++++++++++- asio/src/tests/unit/ip/tcp.cpp | 120 ++++++++++++- asio/src/tests/unit/ip/udp.cpp | 127 +++++++++++++- 58 files changed, 814 insertions(+), 224 deletions(-) create mode 100644 asio/src/tests/unit/archetypes/deprecated_async_result.hpp diff --git a/asio/include/asio/async_result.hpp b/asio/include/asio/async_result.hpp index 12ccd1ec..7d2041fe 100644 --- a/asio/include/asio/async_result.hpp +++ b/asio/include/asio/async_result.hpp @@ -24,11 +24,94 @@ namespace asio { /// An interface for customising the behaviour of an initiating function. +/** + * The async_result traits class is used for determining: + * + * @li the concrete completion handler type to be called at the end of the + * asynchronous operation; + * + * @li the initiating function return type; and + * + * @li how the return value of the initiating function is obtained. + * + * The trait allows the handler and return types to be determined at the point + * where the specific completion handler signature is known. + * + * This template may be specialised for user-defined completion token types. + * The primary template assumes that the CompletionToken is the completion + * handler. + */ +#if defined(ASIO_NO_DEPRECATED) || defined(GENERATING_DOCUMENTATION) +template +#else // defined(ASIO_NO_DEPRECATED) || defined(GENERATING_DOCUMENTATION) +template +#endif // defined(ASIO_NO_DEPRECATED) || defined(GENERATING_DOCUMENTATION) +class async_result +{ +public: +#if defined(ASIO_NO_DEPRECATED) || defined(GENERATING_DOCUMENTATION) + /// The concrete completion handler type for the specific signature. + typedef CompletionToken completion_handler_type; + + /// The return type of the initiating function. + typedef void return_type; +#else // defined(ASIO_NO_DEPRECATED) || defined(GENERATING_DOCUMENTATION) + // For backward compatibility, determine the concrete completion handler type + // by using the legacy handler_type trait. + typedef typename handler_type::type + completion_handler_type; + + // For backward compatibility, determine the initiating function return type + // using the legacy single-parameter version of async_result. + typedef typename async_result::type return_type; +#endif // defined(ASIO_NO_DEPRECATED) || defined(GENERATING_DOCUMENTATION) + + /// Construct an async result from a given handler. + /** + * When using a specalised async_result, the constructor has an opportunity + * to initialise some state associated with the completion handler, which is + * then returned from the initiating function. + */ + explicit async_result(completion_handler_type& h) +#if defined(ASIO_NO_DEPRECATED) || defined(GENERATING_DOCUMENTATION) + // No data members to initialise. +#else // defined(ASIO_NO_DEPRECATED) || defined(GENERATING_DOCUMENTATION) + : legacy_result_(h) +#endif // defined(ASIO_NO_DEPRECATED) || defined(GENERATING_DOCUMENTATION) + { + (void)h; + } + + /// Obtain the value to be returned from the initiating function. + return_type get() + { +#if defined(ASIO_NO_DEPRECATED) || defined(GENERATING_DOCUMENTATION) + // Nothing to do. +#else // defined(ASIO_NO_DEPRECATED) || defined(GENERATING_DOCUMENTATION) + return legacy_result_.get(); +#endif // defined(ASIO_NO_DEPRECATED) || defined(GENERATING_DOCUMENTATION) + } + +private: + async_result(const async_result&) ASIO_DELETED; + async_result& operator=(const async_result&) ASIO_DELETED; + +#if defined(ASIO_NO_DEPRECATED) || defined(GENERATING_DOCUMENTATION) + // No data members. +#else // defined(ASIO_NO_DEPRECATED) || defined(GENERATING_DOCUMENTATION) + async_result legacy_result_; +#endif // defined(ASIO_NO_DEPRECATED) || defined(GENERATING_DOCUMENTATION) +}; + +#if !defined(ASIO_NO_DEPRECATED) + +/// (Deprecated: Use two-parameter version of async_result.) An interface for +/// customising the behaviour of an initiating function. /** * This template may be specialised for user-defined handler types. */ template -class async_result +class async_result { public: /// The return type of the initiating function. @@ -50,33 +133,42 @@ public: } }; -/// Helper template to deduce the real type of a handler, capture a local copy -/// of the handler, and then create an async_result for the handler. -template +#endif // !defined(ASIO_NO_DEPRECATED) + +/// Helper template to deduce the handler type from a CompletionToken, capture +/// a local copy of the handler, and then create an async_result for the +/// handler. +template struct async_completion { /// The real handler type to be used for the asynchronous operation. - typedef typename asio::handler_type< - Handler, Signature>::type handler_type; + typedef typename asio::async_result< + typename decay::type, + Signature>::completion_handler_type completion_handler_type; +#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// Constructor. /** - * The constructor creates the concrete handler and makes the link between - * the handler and the asynchronous result. + * The constructor creates the concrete completion handler and makes the link + * between the handler and the asynchronous result. */ -#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) - explicit async_completion( - Handler& orig_handler) - : handler(static_cast::value, - handler_type&, Handler&&>::type>(orig_handler)), - result(handler) + explicit async_completion(CompletionToken& token) + : completion_handler(static_cast::value, + completion_handler_type&, CompletionToken&&>::type>(token)), + result(completion_handler) { } #else // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) - explicit async_completion(const Handler& orig_handler) - : handler(orig_handler), - result(handler) + explicit async_completion(typename decay::type& token) + : completion_handler(token), + result(completion_handler) + { + } + + explicit async_completion(const typename decay::type& token) + : completion_handler(token), + result(completion_handler) { } #endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) @@ -84,25 +176,22 @@ struct async_completion /// A copy of, or reference to, a real handler object. #if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) typename conditional< - is_same::value, - handler_type&, handler_type>::type handler; + is_same::value, + completion_handler_type&, completion_handler_type>::type completion_handler; #else // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) - typename asio::handler_type::type handler; + completion_handler_type completion_handler; #endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) /// The result of the asynchronous operation's initiating function. - async_result::type> result; + async_result::type, Signature> result; }; namespace detail { -template -struct async_result_type_helper +template +struct async_result_helper + : async_result::type, Signature> { - typedef typename async_result< - typename handler_type::type - >::type type; }; } // namespace detail @@ -111,15 +200,22 @@ struct async_result_type_helper #include "asio/detail/pop_options.hpp" #if defined(GENERATING_DOCUMENTATION) -# define ASIO_INITFN_RESULT_TYPE(h, sig) \ +# define ASIO_INITFN_RESULT_TYPE(ct, sig) \ void_or_deduced #elif defined(_MSC_VER) && (_MSC_VER < 1500) -# define ASIO_INITFN_RESULT_TYPE(h, sig) \ - typename ::asio::detail::async_result_type_helper::type +# define ASIO_INITFN_RESULT_TYPE(ct, sig) \ + typename ::asio::detail::async_result_helper< \ + ct, sig>::return_type +#define ASIO_HANDLER_TYPE(ct, sig) \ + typename ::asio::detail::async_result_helper< \ + ct, sig>::completion_handler_type #else -# define ASIO_INITFN_RESULT_TYPE(h, sig) \ +# define ASIO_INITFN_RESULT_TYPE(ct, sig) \ typename ::asio::async_result< \ - typename ::asio::handler_type::type>::type + typename ::asio::decay::type, sig>::return_type +#define ASIO_HANDLER_TYPE(ct, sig) \ + typename ::asio::async_result< \ + typename ::asio::decay::type, sig>::completion_handler_type #endif #endif // ASIO_ASYNC_RESULT_HPP diff --git a/asio/include/asio/basic_datagram_socket.hpp b/asio/include/asio/basic_datagram_socket.hpp index f72ebbf1..a3339f43 100644 --- a/asio/include/asio/basic_datagram_socket.hpp +++ b/asio/include/asio/basic_datagram_socket.hpp @@ -354,7 +354,7 @@ public: void (asio::error_code, std::size_t)> init(handler); this->get_service().async_send(this->get_implementation(), - buffers, 0, init.handler); + buffers, 0, init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) @@ -407,7 +407,7 @@ public: void (asio::error_code, std::size_t)> init(handler); this->get_service().async_send(this->get_implementation(), - buffers, flags, init.handler); + buffers, flags, init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) @@ -559,7 +559,7 @@ public: this->get_service().async_send_to( this->get_implementation(), buffers, destination, 0, - init.handler); + init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) @@ -613,7 +613,7 @@ public: this->get_service().async_send_to( this->get_implementation(), buffers, destination, flags, - init.handler); + init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) @@ -762,7 +762,7 @@ public: void (asio::error_code, std::size_t)> init(handler); this->get_service().async_receive(this->get_implementation(), - buffers, 0, init.handler); + buffers, 0, init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) @@ -815,7 +815,7 @@ public: void (asio::error_code, std::size_t)> init(handler); this->get_service().async_receive(this->get_implementation(), - buffers, flags, init.handler); + buffers, flags, init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) @@ -967,7 +967,7 @@ public: this->get_service().async_receive_from( this->get_implementation(), buffers, sender_endpoint, 0, - init.handler); + init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) @@ -1023,7 +1023,7 @@ public: this->get_service().async_receive_from( this->get_implementation(), buffers, sender_endpoint, flags, - init.handler); + init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) diff --git a/asio/include/asio/basic_deadline_timer.hpp b/asio/include/asio/basic_deadline_timer.hpp index 24ddec28..2d158846 100644 --- a/asio/include/asio/basic_deadline_timer.hpp +++ b/asio/include/asio/basic_deadline_timer.hpp @@ -571,7 +571,8 @@ public: async_completion init(handler); - this->get_service().async_wait(this->get_implementation(), init.handler); + this->get_service().async_wait(this->get_implementation(), + init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) diff --git a/asio/include/asio/basic_raw_socket.hpp b/asio/include/asio/basic_raw_socket.hpp index b66b75d4..8e12e7ca 100644 --- a/asio/include/asio/basic_raw_socket.hpp +++ b/asio/include/asio/basic_raw_socket.hpp @@ -346,7 +346,7 @@ public: void (asio::error_code, std::size_t)> init(handler); this->get_service().async_send(this->get_implementation(), - buffers, 0, init.handler); + buffers, 0, init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) @@ -399,7 +399,7 @@ public: void (asio::error_code, std::size_t)> init(handler); this->get_service().async_send(this->get_implementation(), - buffers, flags, init.handler); + buffers, flags, init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) @@ -549,7 +549,7 @@ public: void (asio::error_code, std::size_t)> init(handler); this->get_service().async_send_to(this->get_implementation(), - buffers, destination, 0, init.handler); + buffers, destination, 0, init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) @@ -603,7 +603,7 @@ public: this->get_service().async_send_to( this->get_implementation(), buffers, destination, flags, - init.handler); + init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) @@ -752,7 +752,7 @@ public: void (asio::error_code, std::size_t)> init(handler); this->get_service().async_receive(this->get_implementation(), - buffers, 0, init.handler); + buffers, 0, init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) @@ -805,7 +805,7 @@ public: void (asio::error_code, std::size_t)> init(handler); this->get_service().async_receive(this->get_implementation(), - buffers, flags, init.handler); + buffers, flags, init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) @@ -957,7 +957,7 @@ public: this->get_service().async_receive_from( this->get_implementation(), buffers, sender_endpoint, 0, - init.handler); + init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) @@ -1013,7 +1013,7 @@ public: this->get_service().async_receive_from( this->get_implementation(), buffers, sender_endpoint, flags, - init.handler); + init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) diff --git a/asio/include/asio/basic_seq_packet_socket.hpp b/asio/include/asio/basic_seq_packet_socket.hpp index ec2ab8ff..b0b2e79f 100644 --- a/asio/include/asio/basic_seq_packet_socket.hpp +++ b/asio/include/asio/basic_seq_packet_socket.hpp @@ -332,7 +332,7 @@ public: void (asio::error_code, std::size_t)> init(handler); this->get_service().async_send(this->get_implementation(), - buffers, flags, init.handler); + buffers, flags, init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) @@ -531,7 +531,7 @@ public: this->get_service().async_receive_with_flags( this->get_implementation(), buffers, 0, out_flags, - init.handler); + init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) @@ -601,7 +601,7 @@ public: this->get_service().async_receive_with_flags( this->get_implementation(), buffers, in_flags, out_flags, - init.handler); + init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) diff --git a/asio/include/asio/basic_socket.hpp b/asio/include/asio/basic_socket.hpp index c4ae0df1..c62e1eaf 100644 --- a/asio/include/asio/basic_socket.hpp +++ b/asio/include/asio/basic_socket.hpp @@ -812,7 +812,7 @@ public: asio::detail::bind_handler( ASIO_MOVE_CAST(ASIO_HANDLER_TYPE( ConnectHandler, void (asio::error_code)))( - init.handler), ec)); + init.completion_handler), ec)); return init.result.get(); } @@ -826,7 +826,7 @@ public: void (asio::error_code)> init(handler); this->get_service().async_connect( - this->get_implementation(), peer_endpoint, init.handler); + this->get_implementation(), peer_endpoint, init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) @@ -1658,7 +1658,8 @@ public: async_completion init(handler); - this->get_service().async_wait(this->get_implementation(), w, init.handler); + this->get_service().async_wait(this->get_implementation(), + w, init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) diff --git a/asio/include/asio/basic_socket_acceptor.hpp b/asio/include/asio/basic_socket_acceptor.hpp index 3d8b7e5f..2e9da59f 100644 --- a/asio/include/asio/basic_socket_acceptor.hpp +++ b/asio/include/asio/basic_socket_acceptor.hpp @@ -1060,7 +1060,8 @@ public: async_completion init(handler); - this->get_service().async_wait(this->get_implementation(), w, init.handler); + this->get_service().async_wait(this->get_implementation(), + w, init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) @@ -1207,7 +1208,7 @@ public: void (asio::error_code)> init(handler); this->get_service().async_accept(this->get_implementation(), - peer, static_cast(0), init.handler); + peer, static_cast(0), init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) @@ -1344,7 +1345,7 @@ public: void (asio::error_code)> init(handler); this->get_service().async_accept(this->get_implementation(), - peer, &peer_endpoint, init.handler); + peer, &peer_endpoint, init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) @@ -1471,7 +1472,7 @@ public: this->get_service().async_accept( this->get_implementation(), static_cast(0), - static_cast(0), init.handler); + static_cast(0), init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) @@ -1607,7 +1608,7 @@ public: typename Protocol::socket)> init(handler); this->get_service().async_accept(this->get_implementation(), - &io_context, static_cast(0), init.handler); + &io_context, static_cast(0), init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) @@ -1748,7 +1749,8 @@ public: typename Protocol::socket)> init(handler); this->get_service().async_accept(this->get_implementation(), - static_cast(0), &peer_endpoint, init.handler); + static_cast(0), &peer_endpoint, + init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) @@ -1902,7 +1904,7 @@ public: typename Protocol::socket)> init(handler); this->get_service().async_accept(this->get_implementation(), - &io_context, &peer_endpoint, init.handler); + &io_context, &peer_endpoint, init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) diff --git a/asio/include/asio/basic_stream_socket.hpp b/asio/include/asio/basic_stream_socket.hpp index c3eef8ce..0eb76205 100644 --- a/asio/include/asio/basic_stream_socket.hpp +++ b/asio/include/asio/basic_stream_socket.hpp @@ -368,7 +368,7 @@ public: this->get_service().async_send( this->get_implementation(), buffers, 0, - init.handler); + init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) @@ -432,7 +432,7 @@ public: this->get_service().async_send( this->get_implementation(), buffers, flags, - init.handler); + init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) @@ -598,7 +598,7 @@ public: void (asio::error_code, std::size_t)> init(handler); this->get_service().async_receive(this->get_implementation(), - buffers, 0, init.handler); + buffers, 0, init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) @@ -662,7 +662,7 @@ public: void (asio::error_code, std::size_t)> init(handler); this->get_service().async_receive(this->get_implementation(), - buffers, flags, init.handler); + buffers, flags, init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) @@ -781,7 +781,7 @@ public: void (asio::error_code, std::size_t)> init(handler); this->get_service().async_send(this->get_implementation(), - buffers, 0, init.handler); + buffers, 0, init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) @@ -904,7 +904,7 @@ public: void (asio::error_code, std::size_t)> init(handler); this->get_service().async_receive(this->get_implementation(), - buffers, 0, init.handler); + buffers, 0, init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) diff --git a/asio/include/asio/basic_waitable_timer.hpp b/asio/include/asio/basic_waitable_timer.hpp index e6032c38..e38d39e9 100644 --- a/asio/include/asio/basic_waitable_timer.hpp +++ b/asio/include/asio/basic_waitable_timer.hpp @@ -670,7 +670,8 @@ public: async_completion init(handler); - this->get_service().async_wait(this->get_implementation(), init.handler); + this->get_service().async_wait(this->get_implementation(), + init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) diff --git a/asio/include/asio/bind_executor.hpp b/asio/include/asio/bind_executor.hpp index f74a8e3a..4b160a6a 100644 --- a/asio/include/asio/bind_executor.hpp +++ b/asio/include/asio/bind_executor.hpp @@ -20,7 +20,6 @@ #include "asio/detail/variadic_templates.hpp" #include "asio/associated_allocator.hpp" #include "asio/async_result.hpp" -#include "asio/handler_type.hpp" #include "asio/is_executor.hpp" #include "asio/uses_executor.hpp" @@ -519,6 +518,35 @@ template struct uses_executor, Executor> : true_type {}; +template +class async_result, Signature> +{ +public: + typedef executor_binder< + typename async_result::completion_handler_type, Executor> + completion_handler_type; + + typedef typename async_result::return_type return_type; + + explicit async_result(executor_binder& b) + : target_(b.get()) + { + } + + return_type get() + { + return target_.get(); + } + +private: + async_result(const async_result&) ASIO_DELETED; + async_result& operator=(const async_result&) ASIO_DELETED; + + async_result target_; +}; + +#if !defined(ASIO_NO_DEPRECATED) + template struct handler_type, Signature> { @@ -546,6 +574,8 @@ private: async_result target_; }; +#endif // !defined(ASIO_NO_DEPRECATED) + template struct associated_allocator, Allocator> { diff --git a/asio/include/asio/buffered_read_stream.hpp b/asio/include/asio/buffered_read_stream.hpp index daa6f596..832ec176 100644 --- a/asio/include/asio/buffered_read_stream.hpp +++ b/asio/include/asio/buffered_read_stream.hpp @@ -163,7 +163,8 @@ public: next_layer_.async_write_some(buffers, ASIO_MOVE_CAST(ASIO_HANDLER_TYPE(WriteHandler, - void (asio::error_code, std::size_t)))(init.handler)); + void (asio::error_code, std::size_t)))( + init.completion_handler)); return init.result.get(); } diff --git a/asio/include/asio/buffered_write_stream.hpp b/asio/include/asio/buffered_write_stream.hpp index 0fa7547e..9f2641fe 100644 --- a/asio/include/asio/buffered_write_stream.hpp +++ b/asio/include/asio/buffered_write_stream.hpp @@ -198,7 +198,8 @@ public: next_layer_.async_read_some(buffers, ASIO_MOVE_CAST(ASIO_HANDLER_TYPE(ReadHandler, - void (asio::error_code, std::size_t)))(init.handler)); + void (asio::error_code, std::size_t)))( + init.completion_handler)); return init.result.get(); } diff --git a/asio/include/asio/datagram_socket_service.hpp b/asio/include/asio/datagram_socket_service.hpp index e22d07ff..f5786132 100644 --- a/asio/include/asio/datagram_socket_service.hpp +++ b/asio/include/asio/datagram_socket_service.hpp @@ -217,7 +217,7 @@ public: async_completion init(handler); - service_impl_.async_connect(impl, peer_endpoint, init.handler); + service_impl_.async_connect(impl, peer_endpoint, init.completion_handler); return init.result.get(); } @@ -312,7 +312,7 @@ public: async_completion init(handler); - service_impl_.async_wait(impl, w, init.handler); + service_impl_.async_wait(impl, w, init.completion_handler); return init.result.get(); } @@ -337,7 +337,7 @@ public: async_completion init(handler); - service_impl_.async_send(impl, buffers, flags, init.handler); + service_impl_.async_send(impl, buffers, flags, init.completion_handler); return init.result.get(); } @@ -364,7 +364,7 @@ public: void (asio::error_code, std::size_t)> init(handler); service_impl_.async_send_to(impl, buffers, - destination, flags, init.handler); + destination, flags, init.completion_handler); return init.result.get(); } @@ -390,7 +390,7 @@ public: async_completion init(handler); - service_impl_.async_receive(impl, buffers, flags, init.handler); + service_impl_.async_receive(impl, buffers, flags, init.completion_handler); return init.result.get(); } @@ -418,7 +418,7 @@ public: void (asio::error_code, std::size_t)> init(handler); service_impl_.async_receive_from(impl, buffers, - sender_endpoint, flags, init.handler); + sender_endpoint, flags, init.completion_handler); return init.result.get(); } diff --git a/asio/include/asio/deadline_timer_service.hpp b/asio/include/asio/deadline_timer_service.hpp index df87d54c..a51bdae7 100644 --- a/asio/include/asio/deadline_timer_service.hpp +++ b/asio/include/asio/deadline_timer_service.hpp @@ -145,7 +145,7 @@ public: async_completion init(handler); - service_impl_.async_wait(impl, init.handler); + service_impl_.async_wait(impl, init.completion_handler); return init.result.get(); } diff --git a/asio/include/asio/detail/handler_type_requirements.hpp b/asio/include/asio/detail/handler_type_requirements.hpp index 04bab88b..1a7c3596 100644 --- a/asio/include/asio/detail/handler_type_requirements.hpp +++ b/asio/include/asio/detail/handler_type_requirements.hpp @@ -50,7 +50,7 @@ #endif // !defined(ASIO_DISABLE_HANDLER_TYPE_REQUIREMENTS) #if defined(ASIO_ENABLE_HANDLER_TYPE_REQUIREMENTS) -# include "asio/handler_type.hpp" +# include "asio/async_result.hpp" #endif // defined(ASIO_ENABLE_HANDLER_TYPE_REQUIREMENTS) // Newer gcc, clang need special treatment to suppress unused typedef warnings. diff --git a/asio/include/asio/handler_type.hpp b/asio/include/asio/handler_type.hpp index 260fbcb5..809e3639 100644 --- a/asio/include/asio/handler_type.hpp +++ b/asio/include/asio/handler_type.hpp @@ -22,7 +22,8 @@ namespace asio { -/// Default handler type traits provided for all completion token types. +/// (Deprecated: Use two-parameter version of async_result.) Default handler +/// type traits provided for all completion token types. /** * The handler_type traits class is used for determining the concrete handler * type to be used for an asynchronous operation. It allows the handler type to @@ -46,7 +47,4 @@ struct handler_type #include "asio/detail/pop_options.hpp" -#define ASIO_HANDLER_TYPE(h, sig) \ - typename handler_type::type - #endif // ASIO_HANDLER_TYPE_HPP diff --git a/asio/include/asio/impl/buffered_read_stream.hpp b/asio/include/asio/impl/buffered_read_stream.hpp index 77700b8a..5c532557 100644 --- a/asio/include/asio/impl/buffered_read_stream.hpp +++ b/asio/include/asio/impl/buffered_read_stream.hpp @@ -191,7 +191,7 @@ buffered_read_stream::async_fill( storage_.size() - previous_size), detail::buffered_fill_handler( - storage_, previous_size, init.handler)); + storage_, previous_size, init.completion_handler)); return init.result.get(); } @@ -385,14 +385,14 @@ buffered_read_stream::async_read_some( detail::buffered_read_some_handler< MutableBufferSequence, ASIO_HANDLER_TYPE( ReadHandler, void (asio::error_code, std::size_t))>( - storage_, buffers, init.handler)); + storage_, buffers, init.completion_handler)); } else { this->async_fill(detail::buffered_read_some_handler< MutableBufferSequence, ASIO_HANDLER_TYPE( ReadHandler, void (asio::error_code, std::size_t))>( - storage_, buffers, init.handler)); + storage_, buffers, init.completion_handler)); } return init.result.get(); diff --git a/asio/include/asio/impl/buffered_write_stream.hpp b/asio/include/asio/impl/buffered_write_stream.hpp index 125bd310..af55d1c4 100644 --- a/asio/include/asio/impl/buffered_write_stream.hpp +++ b/asio/include/asio/impl/buffered_write_stream.hpp @@ -172,7 +172,7 @@ buffered_write_stream::async_flush( async_write(next_layer_, buffer(storage_.data(), storage_.size()), detail::buffered_flush_handler( - storage_, init.handler)); + storage_, init.completion_handler)); return init.result.get(); } @@ -372,14 +372,14 @@ buffered_write_stream::async_write_some( detail::buffered_write_some_handler< ConstBufferSequence, ASIO_HANDLER_TYPE( WriteHandler, void (asio::error_code, std::size_t))>( - storage_, buffers, init.handler)); + storage_, buffers, init.completion_handler)); } else { this->async_flush(detail::buffered_write_some_handler< ConstBufferSequence, ASIO_HANDLER_TYPE( WriteHandler, void (asio::error_code, std::size_t))>( - storage_, buffers, init.handler)); + storage_, buffers, init.completion_handler)); } return init.result.get(); diff --git a/asio/include/asio/impl/connect.hpp b/asio/include/asio/impl/connect.hpp index f8e38601..8680d12d 100644 --- a/asio/include/asio/impl/connect.hpp +++ b/asio/include/asio/impl/connect.hpp @@ -659,8 +659,8 @@ async_connect(basic_socket& s, detail::default_connect_condition, ASIO_HANDLER_TYPE(RangeConnectHandler, void (asio::error_code, typename Protocol::endpoint))>(s, - endpoints, detail::default_connect_condition(), init.handler)( - asio::error_code(), 1); + endpoints, detail::default_connect_condition(), + init.completion_handler)(asio::error_code(), 1); return init.result.get(); } @@ -685,8 +685,8 @@ async_connect(basic_socket& s, detail::iterator_connect_op(s, - begin, Iterator(), detail::default_connect_condition(), init.handler)( - asio::error_code(), 1); + begin, Iterator(), detail::default_connect_condition(), + init.completion_handler)(asio::error_code(), 1); return init.result.get(); } @@ -711,8 +711,8 @@ async_connect(basic_socket& s, detail::iterator_connect_op(s, - begin, end, detail::default_connect_condition(), init.handler)( - asio::error_code(), 1); + begin, end, detail::default_connect_condition(), + init.completion_handler)(asio::error_code(), 1); return init.result.get(); } @@ -739,7 +739,7 @@ async_connect(basic_socket& s, detail::range_connect_op(s, - endpoints, connect_condition, init.handler)( + endpoints, connect_condition, init.completion_handler)( asio::error_code(), 1); return init.result.get(); @@ -766,7 +766,7 @@ async_connect(basic_socket& s, detail::iterator_connect_op(s, - begin, Iterator(), connect_condition, init.handler)( + begin, Iterator(), connect_condition, init.completion_handler)( asio::error_code(), 1); return init.result.get(); @@ -792,7 +792,7 @@ async_connect(basic_socket& s, detail::iterator_connect_op(s, - begin, end, connect_condition, init.handler)( + begin, end, connect_condition, init.completion_handler)( asio::error_code(), 1); return init.result.get(); diff --git a/asio/include/asio/impl/defer.hpp b/asio/include/asio/impl/defer.hpp index 5a12176a..8cbd7613 100644 --- a/asio/include/asio/impl/defer.hpp +++ b/asio/include/asio/impl/defer.hpp @@ -28,18 +28,19 @@ template ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) defer( ASIO_MOVE_ARG(CompletionToken) token) { - typedef typename handler_type::type handler; - async_completion completion(token); + typedef ASIO_HANDLER_TYPE(CompletionToken, void()) handler; + + async_completion init(token); typename associated_executor::type ex( - (get_associated_executor)(completion.handler)); + (get_associated_executor)(init.completion_handler)); typename associated_allocator::type alloc( - (get_associated_allocator)(completion.handler)); + (get_associated_allocator)(init.completion_handler)); - ex.defer(ASIO_MOVE_CAST(handler)(completion.handler), alloc); + ex.defer(ASIO_MOVE_CAST(handler)(init.completion_handler), alloc); - return completion.result.get(); + return init.result.get(); } template @@ -47,17 +48,18 @@ ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) defer( const Executor& ex, ASIO_MOVE_ARG(CompletionToken) token, typename enable_if::value>::type*) { - typedef typename handler_type::type handler; - async_completion completion(token); + typedef ASIO_HANDLER_TYPE(CompletionToken, void()) handler; + + async_completion init(token); Executor ex1(ex); typename associated_allocator::type alloc( - (get_associated_allocator)(completion.handler)); + (get_associated_allocator)(init.completion_handler)); - ex1.defer(detail::work_dispatcher(completion.handler), alloc); + ex1.defer(detail::work_dispatcher(init.completion_handler), alloc); - return completion.result.get(); + return init.result.get(); } template diff --git a/asio/include/asio/impl/dispatch.hpp b/asio/include/asio/impl/dispatch.hpp index 42d5fa9e..aaeab703 100644 --- a/asio/include/asio/impl/dispatch.hpp +++ b/asio/include/asio/impl/dispatch.hpp @@ -28,18 +28,19 @@ template ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) dispatch( ASIO_MOVE_ARG(CompletionToken) token) { - typedef typename handler_type::type handler; - async_completion completion(token); + typedef ASIO_HANDLER_TYPE(CompletionToken, void()) handler; + + async_completion init(token); typename associated_executor::type ex( - (get_associated_executor)(completion.handler)); + (get_associated_executor)(init.completion_handler)); typename associated_allocator::type alloc( - (get_associated_allocator)(completion.handler)); + (get_associated_allocator)(init.completion_handler)); - ex.dispatch(ASIO_MOVE_CAST(handler)(completion.handler), alloc); + ex.dispatch(ASIO_MOVE_CAST(handler)(init.completion_handler), alloc); - return completion.result.get(); + return init.result.get(); } template @@ -47,17 +48,19 @@ ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) dispatch( const Executor& ex, ASIO_MOVE_ARG(CompletionToken) token, typename enable_if::value>::type*) { - typedef typename handler_type::type handler; - async_completion completion(token); + typedef ASIO_HANDLER_TYPE(CompletionToken, void()) handler; + + async_completion init(token); Executor ex1(ex); typename associated_allocator::type alloc( - (get_associated_allocator)(completion.handler)); + (get_associated_allocator)(init.completion_handler)); - ex1.dispatch(detail::work_dispatcher(completion.handler), alloc); + ex1.dispatch(detail::work_dispatcher( + init.completion_handler), alloc); - return completion.result.get(); + return init.result.get(); } template diff --git a/asio/include/asio/impl/io_context.hpp b/asio/include/asio/impl/io_context.hpp index 2e80c3cb..adcac14e 100644 --- a/asio/include/asio/impl/io_context.hpp +++ b/asio/include/asio/impl/io_context.hpp @@ -84,16 +84,17 @@ io_context::dispatch(ASIO_MOVE_ARG(CompletionHandler) handler) if (impl_.can_dispatch()) { detail::fenced_block b(detail::fenced_block::full); - asio_handler_invoke_helpers::invoke(init.handler, init.handler); + asio_handler_invoke_helpers::invoke( + init.completion_handler, init.completion_handler); } else { // Allocate and construct an operation to wrap the handler. typedef detail::completion_handler< typename handler_type::type> op; - typename op::ptr p = { detail::addressof(init.handler), - op::ptr::allocate(init.handler), 0 }; - p.p = new (p.v) op(init.handler); + typename op::ptr p = { detail::addressof(init.completion_handler), + op::ptr::allocate(init.completion_handler), 0 }; + p.p = new (p.v) op(init.completion_handler); ASIO_HANDLER_CREATION((*this, *p.p, "io_context", this, 0, "dispatch")); @@ -116,14 +117,14 @@ io_context::post(ASIO_MOVE_ARG(CompletionHandler) handler) async_completion init(handler); bool is_continuation = - asio_handler_cont_helpers::is_continuation(init.handler); + asio_handler_cont_helpers::is_continuation(init.completion_handler); // Allocate and construct an operation to wrap the handler. typedef detail::completion_handler< typename handler_type::type> op; - typename op::ptr p = { detail::addressof(init.handler), - op::ptr::allocate(init.handler), 0 }; - p.p = new (p.v) op(init.handler); + typename op::ptr p = { detail::addressof(init.completion_handler), + op::ptr::allocate(init.completion_handler), 0 }; + p.p = new (p.v) op(init.completion_handler); ASIO_HANDLER_CREATION((*this, *p.p, "io_context", this, 0, "post")); diff --git a/asio/include/asio/impl/post.hpp b/asio/include/asio/impl/post.hpp index 5d034d09..659455a1 100644 --- a/asio/include/asio/impl/post.hpp +++ b/asio/include/asio/impl/post.hpp @@ -28,18 +28,19 @@ template ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) post( ASIO_MOVE_ARG(CompletionToken) token) { - typedef typename handler_type::type handler; - async_completion completion(token); + typedef ASIO_HANDLER_TYPE(CompletionToken, void()) handler; + + async_completion init(token); typename associated_executor::type ex( - (get_associated_executor)(completion.handler)); + (get_associated_executor)(init.completion_handler)); typename associated_allocator::type alloc( - (get_associated_allocator)(completion.handler)); + (get_associated_allocator)(init.completion_handler)); - ex.post(ASIO_MOVE_CAST(handler)(completion.handler), alloc); + ex.post(ASIO_MOVE_CAST(handler)(init.completion_handler), alloc); - return completion.result.get(); + return init.result.get(); } template @@ -47,17 +48,18 @@ ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) post( const Executor& ex, ASIO_MOVE_ARG(CompletionToken) token, typename enable_if::value>::type*) { - typedef typename handler_type::type handler; - async_completion completion(token); + typedef ASIO_HANDLER_TYPE(CompletionToken, void()) handler; + + async_completion init(token); Executor ex1(ex); typename associated_allocator::type alloc( - (get_associated_allocator)(completion.handler)); + (get_associated_allocator)(init.completion_handler)); - ex1.post(detail::work_dispatcher(completion.handler), alloc); + ex1.post(detail::work_dispatcher(init.completion_handler), alloc); - return completion.result.get(); + return init.result.get(); } template diff --git a/asio/include/asio/impl/read.hpp b/asio/include/asio/impl/read.hpp index 85457326..3b37d256 100644 --- a/asio/include/asio/impl/read.hpp +++ b/asio/include/asio/impl/read.hpp @@ -645,7 +645,7 @@ async_read(AsyncReadStream& s, const MutableBufferSequence& buffers, detail::read_op( - s, buffers, completion_condition, init.handler)( + s, buffers, completion_condition, init.completion_handler)( asio::error_code(), 0, 1); return init.result.get(); @@ -671,7 +671,7 @@ async_read(AsyncReadStream& s, const MutableBufferSequence& buffers, detail::read_op( - s, buffers, transfer_all(), init.handler)( + s, buffers, transfer_all(), init.completion_handler)( asio::error_code(), 0, 1); return init.result.get(); @@ -897,7 +897,7 @@ async_read(AsyncReadStream& s, CompletionCondition, ASIO_HANDLER_TYPE( ReadHandler, void (asio::error_code, std::size_t))>( s, ASIO_MOVE_CAST(DynamicBufferSequence)(buffers), - completion_condition, init.handler)( + completion_condition, init.completion_handler)( asio::error_code(), 0, 1); return init.result.get(); diff --git a/asio/include/asio/impl/read_at.hpp b/asio/include/asio/impl/read_at.hpp index 22882c63..9a6413bd 100644 --- a/asio/include/asio/impl/read_at.hpp +++ b/asio/include/asio/impl/read_at.hpp @@ -624,7 +624,7 @@ async_read_at(AsyncRandomAccessReadDevice& d, detail::read_at_op( - d, offset, buffers, completion_condition, init.handler)( + d, offset, buffers, completion_condition, init.completion_handler)( asio::error_code(), 0, 1); return init.result.get(); @@ -648,7 +648,7 @@ async_read_at(AsyncRandomAccessReadDevice& d, detail::read_at_op( - d, offset, buffers, transfer_all(), init.handler)( + d, offset, buffers, transfer_all(), init.completion_handler)( asio::error_code(), 0, 1); return init.result.get(); @@ -849,7 +849,7 @@ async_read_at(AsyncRandomAccessReadDevice& d, detail::read_at_streambuf_op( - d, offset, b, completion_condition, init.handler)( + d, offset, b, completion_condition, init.completion_handler)( asio::error_code(), 0, 1); return init.result.get(); @@ -873,7 +873,7 @@ async_read_at(AsyncRandomAccessReadDevice& d, detail::read_at_streambuf_op( - d, offset, b, transfer_all(), init.handler)( + d, offset, b, transfer_all(), init.completion_handler)( asio::error_code(), 0, 1); return init.result.get(); diff --git a/asio/include/asio/impl/read_until.hpp b/asio/include/asio/impl/read_until.hpp index de0569b5..79d98454 100644 --- a/asio/include/asio/impl/read_until.hpp +++ b/asio/include/asio/impl/read_until.hpp @@ -656,7 +656,7 @@ async_read_until(AsyncReadStream& s, ASIO_HANDLER_TYPE(ReadHandler, void (asio::error_code, std::size_t))>( s, ASIO_MOVE_CAST(DynamicBufferSequence)(buffers), - delim, init.handler)(asio::error_code(), 0, 1); + delim, init.completion_handler)(asio::error_code(), 0, 1); return init.result.get(); } @@ -909,7 +909,7 @@ async_read_until(AsyncReadStream& s, ASIO_HANDLER_TYPE(ReadHandler, void (asio::error_code, std::size_t))>( s, ASIO_MOVE_CAST(DynamicBufferSequence)(buffers), - delim, init.handler)(asio::error_code(), 0, 1); + delim, init.completion_handler)(asio::error_code(), 0, 1); return init.result.get(); } @@ -1168,7 +1168,7 @@ async_read_until(AsyncReadStream& s, boost::regex, ASIO_HANDLER_TYPE(ReadHandler, void (asio::error_code, std::size_t))>( s, ASIO_MOVE_CAST(DynamicBufferSequence)(buffers), - expr, init.handler)(asio::error_code(), 0, 1); + expr, init.completion_handler)(asio::error_code(), 0, 1); return init.result.get(); } @@ -1425,7 +1425,8 @@ async_read_until(AsyncReadStream& s, MatchCondition, ASIO_HANDLER_TYPE(ReadHandler, void (asio::error_code, std::size_t))>( s, ASIO_MOVE_CAST(DynamicBufferSequence)(buffers), - match_condition, init.handler)(asio::error_code(), 0, 1); + match_condition, init.completion_handler)( + asio::error_code(), 0, 1); return init.result.get(); } diff --git a/asio/include/asio/impl/spawn.hpp b/asio/include/asio/impl/spawn.hpp index a69df96a..61461d8c 100644 --- a/asio/include/asio/impl/spawn.hpp +++ b/asio/include/asio/impl/spawn.hpp @@ -26,7 +26,6 @@ #include "asio/detail/handler_invoke_helpers.hpp" #include "asio/detail/memory.hpp" #include "asio/detail/noncopyable.hpp" -#include "asio/handler_type.hpp" #include "asio/system_error.hpp" #include "asio/detail/push_options.hpp" diff --git a/asio/include/asio/impl/use_future.hpp b/asio/include/asio/impl/use_future.hpp index fd3857f1..f3f7d590 100644 --- a/asio/include/asio/impl/use_future.hpp +++ b/asio/include/asio/impl/use_future.hpp @@ -19,7 +19,6 @@ #include #include "asio/async_result.hpp" #include "asio/error_code.hpp" -#include "asio/handler_type.hpp" #include "asio/system_error.hpp" #include "asio/detail/push_options.hpp" diff --git a/asio/include/asio/impl/write.hpp b/asio/include/asio/impl/write.hpp index 4fbfc446..af59b8da 100644 --- a/asio/include/asio/impl/write.hpp +++ b/asio/include/asio/impl/write.hpp @@ -705,7 +705,7 @@ async_write(AsyncWriteStream& s, const ConstBufferSequence& buffers, detail::write_op( - s, buffers, completion_condition, init.handler)( + s, buffers, completion_condition, init.completion_handler)( asio::error_code(), 0, 1); return init.result.get(); @@ -731,7 +731,7 @@ async_write(AsyncWriteStream& s, const ConstBufferSequence& buffers, detail::write_op( - s, buffers, transfer_all(), init.handler)( + s, buffers, transfer_all(), init.completion_handler)( asio::error_code(), 0, 1); return init.result.get(); @@ -930,7 +930,7 @@ async_write(AsyncWriteStream& s, CompletionCondition, ASIO_HANDLER_TYPE( WriteHandler, void (asio::error_code, std::size_t))>( s, ASIO_MOVE_CAST(DynamicBufferSequence)(buffers), - completion_condition, init.handler)( + completion_condition, init.completion_handler)( asio::error_code(), 0, 1); return init.result.get(); diff --git a/asio/include/asio/impl/write_at.hpp b/asio/include/asio/impl/write_at.hpp index 9303c5c9..3412ba0b 100644 --- a/asio/include/asio/impl/write_at.hpp +++ b/asio/include/asio/impl/write_at.hpp @@ -686,7 +686,7 @@ async_write_at(AsyncRandomAccessWriteDevice& d, detail::write_at_op( - d, offset, buffers, completion_condition, init.handler)( + d, offset, buffers, completion_condition, init.completion_handler)( asio::error_code(), 0, 1); return init.result.get(); @@ -710,7 +710,7 @@ async_write_at(AsyncRandomAccessWriteDevice& d, detail::write_at_op( - d, offset, buffers, transfer_all(), init.handler)( + d, offset, buffers, transfer_all(), init.completion_handler)( asio::error_code(), 0, 1); return init.result.get(); @@ -860,7 +860,7 @@ async_write_at(AsyncRandomAccessWriteDevice& d, async_write_at(d, offset, b.data(), completion_condition, detail::write_at_streambuf_op( - b, init.handler)); + b, init.completion_handler)); return init.result.get(); } @@ -883,7 +883,7 @@ async_write_at(AsyncRandomAccessWriteDevice& d, async_write_at(d, offset, b.data(), transfer_all(), detail::write_at_streambuf_op( - b, init.handler)); + b, init.completion_handler)); return init.result.get(); } diff --git a/asio/include/asio/io_context_strand.hpp b/asio/include/asio/io_context_strand.hpp index 78bb8547..8c0b0573 100644 --- a/asio/include/asio/io_context_strand.hpp +++ b/asio/include/asio/io_context_strand.hpp @@ -218,7 +218,7 @@ public: async_completion init(handler); - service_.dispatch(impl_, init.handler); + service_.dispatch(impl_, init.completion_handler); return init.result.get(); } @@ -272,7 +272,7 @@ public: async_completion init(handler); - service_.post(impl_, init.handler); + service_.post(impl_, init.completion_handler); return init.result.get(); } diff --git a/asio/include/asio/ip/basic_resolver.hpp b/asio/include/asio/ip/basic_resolver.hpp index ca4f8f93..629a7a5d 100644 --- a/asio/include/asio/ip/basic_resolver.hpp +++ b/asio/include/asio/ip/basic_resolver.hpp @@ -633,7 +633,7 @@ public: void (asio::error_code, results_type)> init(handler); this->get_service().async_resolve( - this->get_implementation(), q, init.handler); + this->get_implementation(), q, init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) @@ -760,7 +760,7 @@ public: void (asio::error_code, results_type)> init(handler); this->get_service().async_resolve( - this->get_implementation(), q, init.handler); + this->get_implementation(), q, init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) @@ -893,7 +893,7 @@ public: void (asio::error_code, results_type)> init(handler); this->get_service().async_resolve( - this->get_implementation(), q, init.handler); + this->get_implementation(), q, init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) @@ -984,7 +984,7 @@ public: void (asio::error_code, results_type)> init(handler); this->get_service().async_resolve( - this->get_implementation(), e, init.handler); + this->get_implementation(), e, init.completion_handler); return init.result.get(); #endif // defined(ASIO_ENABLE_OLD_SERVICES) diff --git a/asio/include/asio/ip/resolver_service.hpp b/asio/include/asio/ip/resolver_service.hpp index ef1a28c3..b8461b87 100644 --- a/asio/include/asio/ip/resolver_service.hpp +++ b/asio/include/asio/ip/resolver_service.hpp @@ -146,7 +146,7 @@ public: asio::async_completion init(handler); - service_impl_.async_resolve(impl, query, init.handler); + service_impl_.async_resolve(impl, query, init.completion_handler); return init.result.get(); } @@ -168,7 +168,7 @@ public: asio::async_completion init(handler); - service_impl_.async_resolve(impl, endpoint, init.handler); + service_impl_.async_resolve(impl, endpoint, init.completion_handler); return init.result.get(); } diff --git a/asio/include/asio/package.hpp b/asio/include/asio/package.hpp index b8158b47..4e5e1c52 100644 --- a/asio/include/asio/package.hpp +++ b/asio/include/asio/package.hpp @@ -21,7 +21,6 @@ #include "asio/async_result.hpp" #include "asio/detail/type_traits.hpp" #include "asio/detail/variadic_templates.hpp" -#include "asio/handler_type.hpp" #include "asio/detail/push_options.hpp" diff --git a/asio/include/asio/posix/descriptor.hpp b/asio/include/asio/posix/descriptor.hpp index cc325364..28b3b9b3 100644 --- a/asio/include/asio/posix/descriptor.hpp +++ b/asio/include/asio/posix/descriptor.hpp @@ -607,7 +607,7 @@ public: void (asio::error_code)> init(handler); this->get_service().async_wait( - this->get_implementation(), w, init.handler); + this->get_implementation(), w, init.completion_handler); return init.result.get(); } diff --git a/asio/include/asio/posix/stream_descriptor.hpp b/asio/include/asio/posix/stream_descriptor.hpp index 3f28ccf3..3a7b6899 100644 --- a/asio/include/asio/posix/stream_descriptor.hpp +++ b/asio/include/asio/posix/stream_descriptor.hpp @@ -226,7 +226,7 @@ public: void (asio::error_code, std::size_t)> init(handler); this->get_service().async_write_some( - this->get_implementation(), buffers, init.handler); + this->get_implementation(), buffers, init.completion_handler); return init.result.get(); } @@ -344,7 +344,7 @@ public: void (asio::error_code, std::size_t)> init(handler); this->get_service().async_read_some( - this->get_implementation(), buffers, init.handler); + this->get_implementation(), buffers, init.completion_handler); return init.result.get(); } diff --git a/asio/include/asio/posix/stream_descriptor_service.hpp b/asio/include/asio/posix/stream_descriptor_service.hpp index ed050cc7..2673fd07 100644 --- a/asio/include/asio/posix/stream_descriptor_service.hpp +++ b/asio/include/asio/posix/stream_descriptor_service.hpp @@ -195,7 +195,7 @@ public: async_completion init(handler); - service_impl_.async_wait(impl, w, init.handler); + service_impl_.async_wait(impl, w, init.completion_handler); return init.result.get(); } @@ -219,7 +219,7 @@ public: asio::async_completion init(handler); - service_impl_.async_write_some(impl, buffers, init.handler); + service_impl_.async_write_some(impl, buffers, init.completion_handler); return init.result.get(); } @@ -243,7 +243,7 @@ public: asio::async_completion init(handler); - service_impl_.async_read_some(impl, buffers, init.handler); + service_impl_.async_read_some(impl, buffers, init.completion_handler); return init.result.get(); } diff --git a/asio/include/asio/raw_socket_service.hpp b/asio/include/asio/raw_socket_service.hpp index 546218a7..9d433b56 100644 --- a/asio/include/asio/raw_socket_service.hpp +++ b/asio/include/asio/raw_socket_service.hpp @@ -217,7 +217,7 @@ public: async_completion init(handler); - service_impl_.async_connect(impl, peer_endpoint, init.handler); + service_impl_.async_connect(impl, peer_endpoint, init.completion_handler); return init.result.get(); } @@ -312,7 +312,7 @@ public: async_completion init(handler); - service_impl_.async_wait(impl, w, init.handler); + service_impl_.async_wait(impl, w, init.completion_handler); return init.result.get(); } @@ -337,7 +337,7 @@ public: async_completion init(handler); - service_impl_.async_send(impl, buffers, flags, init.handler); + service_impl_.async_send(impl, buffers, flags, init.completion_handler); return init.result.get(); } @@ -364,7 +364,7 @@ public: void (asio::error_code, std::size_t)> init(handler); service_impl_.async_send_to(impl, buffers, - destination, flags, init.handler); + destination, flags, init.completion_handler); return init.result.get(); } @@ -390,7 +390,7 @@ public: async_completion init(handler); - service_impl_.async_receive(impl, buffers, flags, init.handler); + service_impl_.async_receive(impl, buffers, flags, init.completion_handler); return init.result.get(); } @@ -418,7 +418,7 @@ public: void (asio::error_code, std::size_t)> init(handler); service_impl_.async_receive_from(impl, buffers, - sender_endpoint, flags, init.handler); + sender_endpoint, flags, init.completion_handler); return init.result.get(); } diff --git a/asio/include/asio/seq_packet_socket_service.hpp b/asio/include/asio/seq_packet_socket_service.hpp index f48efd4b..a79944e7 100644 --- a/asio/include/asio/seq_packet_socket_service.hpp +++ b/asio/include/asio/seq_packet_socket_service.hpp @@ -219,7 +219,7 @@ public: async_completion init(handler); - service_impl_.async_connect(impl, peer_endpoint, init.handler); + service_impl_.async_connect(impl, peer_endpoint, init.completion_handler); return init.result.get(); } @@ -314,7 +314,7 @@ public: async_completion init(handler); - service_impl_.async_wait(impl, w, init.handler); + service_impl_.async_wait(impl, w, init.completion_handler); return init.result.get(); } @@ -340,7 +340,7 @@ public: async_completion init(handler); - service_impl_.async_send(impl, buffers, flags, init.handler); + service_impl_.async_send(impl, buffers, flags, init.completion_handler); return init.result.get(); } @@ -368,7 +368,7 @@ public: void (asio::error_code, std::size_t)> init(handler); service_impl_.async_receive_with_flags(impl, - buffers, in_flags, out_flags, init.handler); + buffers, in_flags, out_flags, init.completion_handler); return init.result.get(); } diff --git a/asio/include/asio/serial_port.hpp b/asio/include/asio/serial_port.hpp index 0f13dc15..ee56835e 100644 --- a/asio/include/asio/serial_port.hpp +++ b/asio/include/asio/serial_port.hpp @@ -625,7 +625,7 @@ public: void (asio::error_code, std::size_t)> init(handler); this->get_service().async_write_some( - this->get_implementation(), buffers, init.handler); + this->get_implementation(), buffers, init.completion_handler); return init.result.get(); } @@ -743,7 +743,7 @@ public: void (asio::error_code, std::size_t)> init(handler); this->get_service().async_read_some( - this->get_implementation(), buffers, init.handler); + this->get_implementation(), buffers, init.completion_handler); return init.result.get(); } diff --git a/asio/include/asio/serial_port_service.hpp b/asio/include/asio/serial_port_service.hpp index d0f2443c..b1197270 100644 --- a/asio/include/asio/serial_port_service.hpp +++ b/asio/include/asio/serial_port_service.hpp @@ -190,7 +190,7 @@ public: async_completion init(handler); - service_impl_.async_write_some(impl, buffers, init.handler); + service_impl_.async_write_some(impl, buffers, init.completion_handler); return init.result.get(); } @@ -214,7 +214,7 @@ public: async_completion init(handler); - service_impl_.async_read_some(impl, buffers, init.handler); + service_impl_.async_read_some(impl, buffers, init.completion_handler); return init.result.get(); } diff --git a/asio/include/asio/signal_set.hpp b/asio/include/asio/signal_set.hpp index aced215f..1632b235 100644 --- a/asio/include/asio/signal_set.hpp +++ b/asio/include/asio/signal_set.hpp @@ -432,7 +432,8 @@ public: async_completion init(handler); - this->get_service().async_wait(this->get_implementation(), init.handler); + this->get_service().async_wait(this->get_implementation(), + init.completion_handler); return init.result.get(); } diff --git a/asio/include/asio/signal_set_service.hpp b/asio/include/asio/signal_set_service.hpp index 2dca96ca..f90942cc 100644 --- a/asio/include/asio/signal_set_service.hpp +++ b/asio/include/asio/signal_set_service.hpp @@ -107,7 +107,7 @@ public: async_completion init(handler); - service_impl_.async_wait(impl, init.handler); + service_impl_.async_wait(impl, init.completion_handler); return init.result.get(); } diff --git a/asio/include/asio/socket_acceptor_service.hpp b/asio/include/asio/socket_acceptor_service.hpp index f8eca27d..3cd5f8c4 100644 --- a/asio/include/asio/socket_acceptor_service.hpp +++ b/asio/include/asio/socket_acceptor_service.hpp @@ -264,7 +264,7 @@ public: async_completion init(handler); - service_impl_.async_wait(impl, w, init.handler); + service_impl_.async_wait(impl, w, init.completion_handler); return init.result.get(); } @@ -302,7 +302,8 @@ public: async_completion init(handler); - service_impl_.async_accept(impl, peer, peer_endpoint, init.handler); + service_impl_.async_accept(impl, + peer, peer_endpoint, init.completion_handler); return init.result.get(); } @@ -321,7 +322,7 @@ public: typename Protocol::socket)> init(handler); service_impl_.async_accept(impl, - peer_io_context, peer_endpoint, init.handler); + peer_io_context, peer_endpoint, init.completion_handler); return init.result.get(); } diff --git a/asio/include/asio/stream_socket_service.hpp b/asio/include/asio/stream_socket_service.hpp index 710111cd..c1dbb34a 100644 --- a/asio/include/asio/stream_socket_service.hpp +++ b/asio/include/asio/stream_socket_service.hpp @@ -217,7 +217,7 @@ public: async_completion init(handler); - service_impl_.async_connect(impl, peer_endpoint, init.handler); + service_impl_.async_connect(impl, peer_endpoint, init.completion_handler); return init.result.get(); } @@ -312,7 +312,7 @@ public: async_completion init(handler); - service_impl_.async_wait(impl, w, init.handler); + service_impl_.async_wait(impl, w, init.completion_handler); return init.result.get(); } @@ -338,7 +338,7 @@ public: async_completion init(handler); - service_impl_.async_send(impl, buffers, flags, init.handler); + service_impl_.async_send(impl, buffers, flags, init.completion_handler); return init.result.get(); } @@ -364,7 +364,7 @@ public: async_completion init(handler); - service_impl_.async_receive(impl, buffers, flags, init.handler); + service_impl_.async_receive(impl, buffers, flags, init.completion_handler); return init.result.get(); } diff --git a/asio/include/asio/waitable_timer_service.hpp b/asio/include/asio/waitable_timer_service.hpp index 0e403e57..470d1760 100644 --- a/asio/include/asio/waitable_timer_service.hpp +++ b/asio/include/asio/waitable_timer_service.hpp @@ -185,7 +185,7 @@ public: async_completion init(handler); - service_impl_.async_wait(impl, init.handler); + service_impl_.async_wait(impl, init.completion_handler); return init.result.get(); } diff --git a/asio/include/asio/windows/object_handle.hpp b/asio/include/asio/windows/object_handle.hpp index 5efd5688..c02e35fc 100644 --- a/asio/include/asio/windows/object_handle.hpp +++ b/asio/include/asio/windows/object_handle.hpp @@ -357,7 +357,8 @@ public: asio::async_completion init(handler); - this->get_service().async_wait(this->get_implementation(), init.handler); + this->get_service().async_wait(this->get_implementation(), + init.completion_handler); return init.result.get(); } diff --git a/asio/include/asio/windows/object_handle_service.hpp b/asio/include/asio/windows/object_handle_service.hpp index 3db67326..fd78ac9c 100644 --- a/asio/include/asio/windows/object_handle_service.hpp +++ b/asio/include/asio/windows/object_handle_service.hpp @@ -151,7 +151,7 @@ public: asio::async_completion init(handler); - service_impl_.async_wait(impl, init.handler); + service_impl_.async_wait(impl, init.completion_handler); return init.result.get(); } diff --git a/asio/include/asio/windows/random_access_handle.hpp b/asio/include/asio/windows/random_access_handle.hpp index b57e80c6..07e2c9de 100644 --- a/asio/include/asio/windows/random_access_handle.hpp +++ b/asio/include/asio/windows/random_access_handle.hpp @@ -234,7 +234,7 @@ public: void (asio::error_code, std::size_t)> init(handler); this->get_service().async_write_some_at(this->get_implementation(), - offset, buffers, init.handler); + offset, buffers, init.completion_handler); return init.result.get(); } @@ -360,7 +360,7 @@ public: void (asio::error_code, std::size_t)> init(handler); this->get_service().async_read_some_at(this->get_implementation(), - offset, buffers, init.handler); + offset, buffers, init.completion_handler); return init.result.get(); } diff --git a/asio/include/asio/windows/random_access_handle_service.hpp b/asio/include/asio/windows/random_access_handle_service.hpp index 2d57ee14..1eb6eb0a 100644 --- a/asio/include/asio/windows/random_access_handle_service.hpp +++ b/asio/include/asio/windows/random_access_handle_service.hpp @@ -156,7 +156,8 @@ public: asio::async_completion init(handler); - service_impl_.async_write_some_at(impl, offset, buffers, init.handler); + service_impl_.async_write_some_at(impl, + offset, buffers, init.completion_handler); return init.result.get(); } @@ -180,7 +181,8 @@ public: asio::async_completion init(handler); - service_impl_.async_read_some_at(impl, offset, buffers, init.handler); + service_impl_.async_read_some_at(impl, + offset, buffers, init.completion_handler); return init.result.get(); } diff --git a/asio/include/asio/windows/stream_handle.hpp b/asio/include/asio/windows/stream_handle.hpp index a150fce2..54e0bcde 100644 --- a/asio/include/asio/windows/stream_handle.hpp +++ b/asio/include/asio/windows/stream_handle.hpp @@ -226,7 +226,7 @@ public: void (asio::error_code, std::size_t)> init(handler); this->get_service().async_write_some( - this->get_implementation(), buffers, init.handler); + this->get_implementation(), buffers, init.completion_handler); return init.result.get(); } @@ -344,7 +344,7 @@ public: void (asio::error_code, std::size_t)> init(handler); this->get_service().async_read_some( - this->get_implementation(), buffers, init.handler); + this->get_implementation(), buffers, init.completion_handler); return init.result.get(); } diff --git a/asio/include/asio/windows/stream_handle_service.hpp b/asio/include/asio/windows/stream_handle_service.hpp index 9f4cf686..18857aaa 100644 --- a/asio/include/asio/windows/stream_handle_service.hpp +++ b/asio/include/asio/windows/stream_handle_service.hpp @@ -154,7 +154,7 @@ public: asio::async_completion init(handler); - service_impl_.async_write_some(impl, buffers, init.handler); + service_impl_.async_write_some(impl, buffers, init.completion_handler); return init.result.get(); } @@ -178,7 +178,7 @@ public: asio::async_completion init(handler); - service_impl_.async_read_some(impl, buffers, init.handler); + service_impl_.async_read_some(impl, buffers, init.completion_handler); return init.result.get(); } diff --git a/asio/src/tests/Makefile.am b/asio/src/tests/Makefile.am index 81ac6132..b7ac7557 100644 --- a/asio/src/tests/Makefile.am +++ b/asio/src/tests/Makefile.am @@ -366,6 +366,7 @@ EXTRA_DIST = \ latency/allocator.hpp \ performance/handler_allocator.hpp \ unit/archetypes/async_result.hpp \ + unit/archetypes/deprecated_async_result.hpp \ unit/archetypes/gettable_socket_option.hpp \ unit/archetypes/io_control_command.hpp \ unit/archetypes/settable_socket_option.hpp diff --git a/asio/src/tests/unit/archetypes/async_result.hpp b/asio/src/tests/unit/archetypes/async_result.hpp index 96cf76a4..d060e8a4 100644 --- a/asio/src/tests/unit/archetypes/async_result.hpp +++ b/asio/src/tests/unit/archetypes/async_result.hpp @@ -12,7 +12,6 @@ #define ARCHETYPES_ASYNC_RESULT_HPP #include -#include namespace archetypes { @@ -48,28 +47,30 @@ private: namespace asio { template -struct handler_type -{ - typedef archetypes::concrete_handler type; -}; - -template <> -class async_result +class async_result { public: + // The concrete completion handler type. + typedef archetypes::concrete_handler completion_handler_type; + // The return type of the initiating function. - typedef int type; + typedef int return_type; // Construct an async_result from a given handler. - explicit async_result(archetypes::concrete_handler&) + explicit async_result(completion_handler_type&) { } // Obtain the value to be returned from the initiating function. - type get() + return_type get() { return 42; } + +private: + // Disallow copying and assignment. + async_result(const async_result&) ASIO_DELETED; + async_result& operator=(const async_result&) ASIO_DELETED; }; } // namespace asio diff --git a/asio/src/tests/unit/archetypes/deprecated_async_result.hpp b/asio/src/tests/unit/archetypes/deprecated_async_result.hpp new file mode 100644 index 00000000..fd9c043d --- /dev/null +++ b/asio/src/tests/unit/archetypes/deprecated_async_result.hpp @@ -0,0 +1,82 @@ +// +// async_result.hpp +// ~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2015 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_RESULT_HPP +#define ARCHETYPES_DEPRECATED_ASYNC_RESULT_HPP + +#include + +#if !defined(ASIO_NO_DEPRECATED) + +#include + +namespace archetypes { + +struct deprecated_lazy_handler +{ +}; + +struct deprecated_concrete_handler +{ + deprecated_concrete_handler(deprecated_lazy_handler) + { + } + + template + void operator()(Arg1) + { + } + + template + void operator()(Arg1, Arg2) + { + } + +#if defined(ASIO_HAS_MOVE) + deprecated_concrete_handler(deprecated_concrete_handler&&) {} +private: + deprecated_concrete_handler(const deprecated_concrete_handler&); +#endif // defined(ASIO_HAS_MOVE) +}; + +} // namespace archetypes + +namespace asio { + +template +struct handler_type +{ + typedef archetypes::deprecated_concrete_handler type; +}; + +template <> +class async_result +{ +public: + // The return type of the initiating function. + typedef double type; + + // Construct an async_result from a given handler. + explicit async_result(archetypes::deprecated_concrete_handler&) + { + } + + // Obtain the value to be returned from the initiating function. + type get() + { + return 42; + } +}; + +} // namespace asio + +#endif // !defined(ASIO_NO_DEPRECATED) + +#endif // ARCHETYPES_DEPRECATED_ASYNC_RESULT_HPP diff --git a/asio/src/tests/unit/ip/icmp.cpp b/asio/src/tests/unit/ip/icmp.cpp index 9d27fac6..77606d12 100644 --- a/asio/src/tests/unit/ip/icmp.cpp +++ b/asio/src/tests/unit/ip/icmp.cpp @@ -20,8 +20,9 @@ #include "asio/io_context.hpp" #include "asio/placeholders.hpp" #include "../unit_test.hpp" -#include "../archetypes/gettable_socket_option.hpp" #include "../archetypes/async_result.hpp" +#include "../archetypes/deprecated_async_result.hpp" +#include "../archetypes/gettable_socket_option.hpp" #include "../archetypes/io_control_command.hpp" #include "../archetypes/settable_socket_option.hpp" @@ -86,6 +87,9 @@ void test() archetypes::gettable_socket_option gettable_socket_option3; archetypes::io_control_command io_control_command; archetypes::lazy_handler lazy; +#if !defined(ASIO_NO_DEPRECATED) + archetypes::deprecated_lazy_handler dlazy; +#endif // !defined(ASIO_NO_DEPRECATED) asio::error_code ec; // basic_datagram_socket constructors. @@ -182,6 +186,14 @@ void test() (void)i1; int i2 = socket1.async_connect(ip::icmp::endpoint(ip::icmp::v6(), 0), lazy); (void)i2; +#if !defined(ASIO_NO_DEPRECATED) + double d1 = socket1.async_connect( + ip::icmp::endpoint(ip::icmp::v4(), 0), dlazy); + (void)d1; + double d2 = socket1.async_connect( + ip::icmp::endpoint(ip::icmp::v6(), 0), dlazy); + (void)d2; +#endif // !defined(ASIO_NO_DEPRECATED) socket1.set_option(settable_socket_option1); socket1.set_option(settable_socket_option1, ec); @@ -249,6 +261,21 @@ void test() (void)i7; int i8 = socket1.async_send(null_buffers(), in_flags, lazy); (void)i8; +#if !defined(ASIO_NO_DEPRECATED) + double d3 = socket1.async_send(buffer(mutable_char_buffer), dlazy); + (void)d3; + double d4 = socket1.async_send(buffer(const_char_buffer), dlazy); + (void)d4; + double d5 = socket1.async_send(null_buffers(), dlazy); + (void)d5; + double d6 = socket1.async_send( + buffer(mutable_char_buffer), in_flags, dlazy); + (void)d6; + double d7 = socket1.async_send(buffer(const_char_buffer), in_flags, dlazy); + (void)d7; + double d8 = socket1.async_send(null_buffers(), in_flags, dlazy); + (void)d8; +#endif // !defined(ASIO_NO_DEPRECATED) socket1.send_to(buffer(mutable_char_buffer), ip::icmp::endpoint(ip::icmp::v4(), 0)); @@ -347,6 +374,44 @@ void test() int i20 = socket1.async_send_to(null_buffers(), ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, lazy); (void)i20; +#if !defined(ASIO_NO_DEPRECATED) + double d9 = socket1.async_send_to(buffer(mutable_char_buffer), + ip::icmp::endpoint(ip::icmp::v4(), 0), dlazy); + (void)d9; + double d10 = socket1.async_send_to(buffer(mutable_char_buffer), + ip::icmp::endpoint(ip::icmp::v6(), 0), dlazy); + (void)d10; + double d11 = socket1.async_send_to(buffer(const_char_buffer), + ip::icmp::endpoint(ip::icmp::v4(), 0), dlazy); + (void)d11; + double d12 = socket1.async_send_to(buffer(const_char_buffer), + ip::icmp::endpoint(ip::icmp::v6(), 0), dlazy); + (void)d12; + double d13 = socket1.async_send_to(null_buffers(), + ip::icmp::endpoint(ip::icmp::v4(), 0), dlazy); + (void)d13; + double d14 = socket1.async_send_to(null_buffers(), + ip::icmp::endpoint(ip::icmp::v6(), 0), dlazy); + (void)d14; + double d15 = socket1.async_send_to(buffer(mutable_char_buffer), + ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags, dlazy); + (void)d15; + double d16 = socket1.async_send_to(buffer(mutable_char_buffer), + ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, dlazy); + (void)d16; + double d17 = socket1.async_send_to(buffer(const_char_buffer), + ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags, dlazy); + (void)d17; + double d18 = socket1.async_send_to(buffer(const_char_buffer), + ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, dlazy); + (void)d18; + double d19 = socket1.async_send_to(null_buffers(), + ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags, dlazy); + (void)d19; + double d20 = socket1.async_send_to(null_buffers(), + ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, dlazy); + (void)d20; +#endif // !defined(ASIO_NO_DEPRECATED) socket1.receive(buffer(mutable_char_buffer)); socket1.receive(null_buffers()); @@ -369,6 +434,17 @@ void test() (void)i23; int i24 = socket1.async_receive(null_buffers(), in_flags, lazy); (void)i24; +#if !defined(ASIO_NO_DEPRECATED) + double d21 = socket1.async_receive(buffer(mutable_char_buffer), dlazy); + (void)d21; + double d22 = socket1.async_receive(null_buffers(), dlazy); + (void)d22; + double d23 = socket1.async_receive(buffer(mutable_char_buffer), + in_flags, dlazy); + (void)d23; + double d24 = socket1.async_receive(null_buffers(), in_flags, dlazy); + (void)d24; +#endif // !defined(ASIO_NO_DEPRECATED) ip::icmp::endpoint endpoint; socket1.receive_from(buffer(mutable_char_buffer), endpoint); @@ -398,6 +474,20 @@ void test() int i28 = socket1.async_receive_from(null_buffers(), endpoint, in_flags, lazy); (void)i28; +#if !defined(ASIO_NO_DEPRECATED) + double d25 = socket1.async_receive_from(buffer(mutable_char_buffer), + endpoint, dlazy); + (void)d25; + double d26 = socket1.async_receive_from(null_buffers(), + endpoint, dlazy); + (void)d26; + double d27 = socket1.async_receive_from(buffer(mutable_char_buffer), + endpoint, in_flags, dlazy); + (void)d27; + double d28 = socket1.async_receive_from(null_buffers(), + endpoint, in_flags, dlazy); + (void)d28; +#endif // !defined(ASIO_NO_DEPRECATED) } catch (std::exception&) { @@ -436,6 +526,9 @@ void test() { io_context ioc; archetypes::lazy_handler lazy; +#if !defined(ASIO_NO_DEPRECATED) + archetypes::deprecated_lazy_handler dlazy; +#endif // !defined(ASIO_NO_DEPRECATED) asio::error_code ec; ip::icmp::resolver::query q(ip::icmp::v4(), "localhost", "0"); ip::icmp::endpoint e(ip::address_v4::loopback(), 0); @@ -530,6 +623,34 @@ void test() resolver.async_resolve(e, resolve_handler()); int i6 = resolver.async_resolve(e, lazy); (void)i6; + +#if !defined(ASIO_NO_DEPRECATED) + resolver.async_resolve(q, resolve_handler()); + double d1 = resolver.async_resolve(q, dlazy); + (void)d1; + + resolver.async_resolve(q, resolve_handler()); + double d2 = resolver.async_resolve("", "", dlazy); + (void)d2; + + resolver.async_resolve(q, resolve_handler()); + double d3 = resolver.async_resolve("", "", + ip::icmp::resolver::flags(), dlazy); + (void)d3; + + resolver.async_resolve(q, resolve_handler()); + double d4 = resolver.async_resolve(ip::icmp::v4(), "", "", dlazy); + (void)d4; + + resolver.async_resolve(q, resolve_handler()); + double d5 = resolver.async_resolve(ip::icmp::v4(), + "", "", ip::icmp::resolver::flags(), dlazy); + (void)d5; + + resolver.async_resolve(e, resolve_handler()); + double d6 = resolver.async_resolve(e, dlazy); + (void)d6; +#endif // !defined(ASIO_NO_DEPRECATED) } catch (std::exception&) { diff --git a/asio/src/tests/unit/ip/tcp.cpp b/asio/src/tests/unit/ip/tcp.cpp index a3165df1..4b2f49d9 100644 --- a/asio/src/tests/unit/ip/tcp.cpp +++ b/asio/src/tests/unit/ip/tcp.cpp @@ -24,8 +24,9 @@ #include "asio/read.hpp" #include "asio/write.hpp" #include "../unit_test.hpp" -#include "../archetypes/gettable_socket_option.hpp" #include "../archetypes/async_result.hpp" +#include "../archetypes/deprecated_async_result.hpp" +#include "../archetypes/gettable_socket_option.hpp" #include "../archetypes/io_control_command.hpp" #include "../archetypes/settable_socket_option.hpp" @@ -234,6 +235,9 @@ void test() archetypes::gettable_socket_option gettable_socket_option3; archetypes::io_control_command io_control_command; archetypes::lazy_handler lazy; +#if !defined(ASIO_NO_DEPRECATED) + archetypes::deprecated_lazy_handler dlazy; +#endif // !defined(ASIO_NO_DEPRECATED) asio::error_code ec; // basic_stream_socket constructors. @@ -333,6 +337,14 @@ void test() (void)i1; int i2 = socket1.async_connect(ip::tcp::endpoint(ip::tcp::v6(), 0), lazy); (void)i2; +#if !defined(ASIO_NO_DEPRECATED) + double d1 = socket1.async_connect( + ip::tcp::endpoint(ip::tcp::v4(), 0), dlazy); + (void)d1; + double d2 = socket1.async_connect( + ip::tcp::endpoint(ip::tcp::v6(), 0), dlazy); + (void)d2; +#endif // !defined(ASIO_NO_DEPRECATED) socket1.set_option(settable_socket_option1); socket1.set_option(settable_socket_option1, ec); @@ -376,6 +388,10 @@ void test() socket1.async_wait(socket_base::wait_read, wait_handler()); int i3 = socket1.async_wait(socket_base::wait_write, lazy); (void)i3; +#if !defined(ASIO_NO_DEPRECATED) + double d3 = socket1.async_wait(socket_base::wait_write, dlazy); + (void)d3; +#endif // !defined(ASIO_NO_DEPRECATED) // basic_stream_socket functions. @@ -425,6 +441,29 @@ void test() (void)i12; int i13 = socket1.async_send(null_buffers(), in_flags, lazy); (void)i13; +#if !defined(ASIO_NO_DEPRECATED) + double d4 = socket1.async_send(buffer(mutable_char_buffer), dlazy); + (void)d4; + double d5 = socket1.async_send(buffer(const_char_buffer), dlazy); + (void)d5; + double d6 = socket1.async_send(mutable_buffers, dlazy); + (void)d6; + double d7 = socket1.async_send(const_buffers, dlazy); + (void)d7; + double d8 = socket1.async_send(null_buffers(), dlazy); + (void)d8; + double d9 = socket1.async_send( + buffer(mutable_char_buffer), in_flags, dlazy); + (void)d9; + double d10 = socket1.async_send(buffer(const_char_buffer), in_flags, dlazy); + (void)d10; + double d11 = socket1.async_send(mutable_buffers, in_flags, dlazy); + (void)d11; + double d12 = socket1.async_send(const_buffers, in_flags, dlazy); + (void)d12; + double d13 = socket1.async_send(null_buffers(), in_flags, dlazy); + (void)d13; +#endif // !defined(ASIO_NO_DEPRECATED) socket1.receive(buffer(mutable_char_buffer)); socket1.receive(mutable_buffers); @@ -456,6 +495,21 @@ void test() (void)i18; int i19 = socket1.async_receive(null_buffers(), in_flags, lazy); (void)i19; +#if !defined(ASIO_NO_DEPRECATED) + double d14 = socket1.async_receive(buffer(mutable_char_buffer), dlazy); + (void)d14; + double d15 = socket1.async_receive(mutable_buffers, dlazy); + (void)d15; + double d16 = socket1.async_receive(null_buffers(), dlazy); + (void)d16; + double d17 = socket1.async_receive(buffer(mutable_char_buffer), in_flags, + dlazy); + (void)d17; + double d18 = socket1.async_receive(mutable_buffers, in_flags, dlazy); + (void)d18; + double d19 = socket1.async_receive(null_buffers(), in_flags, dlazy); + (void)d19; +#endif // !defined(ASIO_NO_DEPRECATED) socket1.write_some(buffer(mutable_char_buffer)); socket1.write_some(buffer(const_char_buffer)); @@ -483,6 +537,18 @@ void test() (void)i23; int i24 = socket1.async_write_some(null_buffers(), lazy); (void)i24; +#if !defined(ASIO_NO_DEPRECATED) + double d20 = socket1.async_write_some(buffer(mutable_char_buffer), dlazy); + (void)d20; + double d21 = socket1.async_write_some(buffer(const_char_buffer), dlazy); + (void)d21; + double d22 = socket1.async_write_some(mutable_buffers, dlazy); + (void)d22; + double d23 = socket1.async_write_some(const_buffers, dlazy); + (void)d23; + double d24 = socket1.async_write_some(null_buffers(), dlazy); + (void)d24; +#endif // !defined(ASIO_NO_DEPRECATED) socket1.read_some(buffer(mutable_char_buffer)); socket1.read_some(mutable_buffers); @@ -500,6 +566,14 @@ void test() (void)i26; int i27 = socket1.async_read_some(null_buffers(), lazy); (void)i27; +#if !defined(ASIO_NO_DEPRECATED) + double d25 = socket1.async_read_some(buffer(mutable_char_buffer), dlazy); + (void)d25; + double d26 = socket1.async_read_some(mutable_buffers, dlazy); + (void)d26; + double d27 = socket1.async_read_some(null_buffers(), dlazy); + (void)d27; +#endif // !defined(ASIO_NO_DEPRECATED) } catch (std::exception&) { @@ -732,6 +806,9 @@ void test() archetypes::gettable_socket_option gettable_socket_option3; archetypes::io_control_command io_control_command; archetypes::lazy_handler lazy; +#if !defined(ASIO_NO_DEPRECATED) + archetypes::deprecated_lazy_handler dlazy; +#endif // !defined(ASIO_NO_DEPRECATED) asio::error_code ec; // basic_socket_acceptor constructors. @@ -833,6 +910,10 @@ void test() acceptor1.async_wait(socket_base::wait_read, wait_handler()); int i1 = acceptor1.async_wait(socket_base::wait_write, lazy); (void)i1; +#if !defined(ASIO_NO_DEPRECATED) + double d1 = acceptor1.async_wait(socket_base::wait_write, dlazy); + (void)d1; +#endif // !defined(ASIO_NO_DEPRECATED) acceptor1.accept(peer_socket); acceptor1.accept(peer_socket, ec); @@ -853,6 +934,12 @@ void test() (void)i2; int i3 = acceptor1.async_accept(peer_socket, peer_endpoint, lazy); (void)i3; +#if !defined(ASIO_NO_DEPRECATED) + double d2 = acceptor1.async_accept(peer_socket, dlazy); + (void)d2; + double d3 = acceptor1.async_accept(peer_socket, peer_endpoint, dlazy); + (void)d3; +#endif // !defined(ASIO_NO_DEPRECATED) #if defined(ASIO_HAS_MOVE) acceptor1.async_accept(move_accept_handler()); @@ -977,6 +1064,9 @@ void test() { io_context ioc; archetypes::lazy_handler lazy; +#if !defined(ASIO_NO_DEPRECATED) + archetypes::deprecated_lazy_handler dlazy; +#endif // !defined(ASIO_NO_DEPRECATED) asio::error_code ec; ip::tcp::resolver::query q(ip::tcp::v4(), "localhost", "0"); ip::tcp::endpoint e(ip::address_v4::loopback(), 0); @@ -1071,6 +1161,34 @@ void test() resolver.async_resolve(e, resolve_handler()); int i6 = resolver.async_resolve(e, lazy); (void)i6; + +#if !defined(ASIO_NO_DEPRECATED) + resolver.async_resolve(q, resolve_handler()); + double d1 = resolver.async_resolve(q, dlazy); + (void)d1; + + resolver.async_resolve(q, resolve_handler()); + double d2 = resolver.async_resolve("", "", dlazy); + (void)d2; + + resolver.async_resolve(q, resolve_handler()); + double d3 = resolver.async_resolve("", "", + ip::tcp::resolver::flags(), dlazy); + (void)d3; + + resolver.async_resolve(q, resolve_handler()); + double d4 = resolver.async_resolve(ip::tcp::v4(), "", "", dlazy); + (void)d4; + + resolver.async_resolve(q, resolve_handler()); + double d5 = resolver.async_resolve(ip::tcp::v4(), + "", "", ip::tcp::resolver::flags(), dlazy); + (void)d5; + + resolver.async_resolve(e, resolve_handler()); + double d6 = resolver.async_resolve(e, dlazy); + (void)d6; +#endif // !defined(ASIO_NO_DEPRECATED) } catch (std::exception&) { diff --git a/asio/src/tests/unit/ip/udp.cpp b/asio/src/tests/unit/ip/udp.cpp index f8417d69..8436d3de 100644 --- a/asio/src/tests/unit/ip/udp.cpp +++ b/asio/src/tests/unit/ip/udp.cpp @@ -19,8 +19,9 @@ #include #include "asio/io_context.hpp" #include "../unit_test.hpp" -#include "../archetypes/gettable_socket_option.hpp" #include "../archetypes/async_result.hpp" +#include "../archetypes/deprecated_async_result.hpp" +#include "../archetypes/gettable_socket_option.hpp" #include "../archetypes/io_control_command.hpp" #include "../archetypes/settable_socket_option.hpp" @@ -102,6 +103,9 @@ void test() archetypes::gettable_socket_option gettable_socket_option3; archetypes::io_control_command io_control_command; archetypes::lazy_handler lazy; +#if !defined(ASIO_NO_DEPRECATED) + archetypes::deprecated_lazy_handler dlazy; +#endif // !defined(ASIO_NO_DEPRECATED) asio::error_code ec; // basic_datagram_socket constructors. @@ -201,6 +205,14 @@ void test() (void)i1; int i2 = socket1.async_connect(ip::udp::endpoint(ip::udp::v6(), 0), lazy); (void)i2; +#if !defined(ASIO_NO_DEPRECATED) + double d1 = socket1.async_connect( + ip::udp::endpoint(ip::udp::v4(), 0), dlazy); + (void)d1; + double d2 = socket1.async_connect( + ip::udp::endpoint(ip::udp::v6(), 0), dlazy); + (void)d2; +#endif // !defined(ASIO_NO_DEPRECATED) socket1.set_option(settable_socket_option1); socket1.set_option(settable_socket_option1, ec); @@ -244,6 +256,10 @@ void test() socket1.async_wait(socket_base::wait_read, wait_handler()); int i3 = socket1.async_wait(socket_base::wait_write, lazy); (void)i3; +#if !defined(ASIO_NO_DEPRECATED) + double d3 = socket1.async_wait(socket_base::wait_write, dlazy); + (void)d3; +#endif // !defined(ASIO_NO_DEPRECATED) // basic_datagram_socket functions. @@ -275,6 +291,21 @@ void test() (void)i8; int i9 = socket1.async_send(null_buffers(), in_flags, lazy); (void)i9; +#if !defined(ASIO_NO_DEPRECATED) + double d4 = socket1.async_send(buffer(mutable_char_buffer), dlazy); + (void)d4; + double d5 = socket1.async_send(buffer(const_char_buffer), dlazy); + (void)d5; + double d6 = socket1.async_send(null_buffers(), dlazy); + (void)d6; + double d7 = socket1.async_send( + buffer(mutable_char_buffer), in_flags, dlazy); + (void)d7; + double d8 = socket1.async_send(buffer(const_char_buffer), in_flags, dlazy); + (void)d8; + double d9 = socket1.async_send(null_buffers(), in_flags, dlazy); + (void)d9; +#endif // !defined(ASIO_NO_DEPRECATED) socket1.send_to(buffer(mutable_char_buffer), ip::udp::endpoint(ip::udp::v4(), 0)); @@ -373,6 +404,44 @@ void test() int i21 = socket1.async_send_to(null_buffers(), ip::udp::endpoint(ip::udp::v6(), 0), in_flags, lazy); (void)i21; +#if !defined(ASIO_NO_DEPRECATED) + double d10 = socket1.async_send_to(buffer(mutable_char_buffer), + ip::udp::endpoint(ip::udp::v4(), 0), dlazy); + (void)d10; + double d11 = socket1.async_send_to(buffer(mutable_char_buffer), + ip::udp::endpoint(ip::udp::v6(), 0), dlazy); + (void)d11; + double d12 = socket1.async_send_to(buffer(const_char_buffer), + ip::udp::endpoint(ip::udp::v4(), 0), dlazy); + (void)d12; + double d13 = socket1.async_send_to(buffer(const_char_buffer), + ip::udp::endpoint(ip::udp::v6(), 0), dlazy); + (void)d13; + double d14 = socket1.async_send_to(null_buffers(), + ip::udp::endpoint(ip::udp::v4(), 0), dlazy); + (void)d14; + double d15 = socket1.async_send_to(null_buffers(), + ip::udp::endpoint(ip::udp::v6(), 0), dlazy); + (void)d15; + double d16 = socket1.async_send_to(buffer(mutable_char_buffer), + ip::udp::endpoint(ip::udp::v4(), 0), in_flags, dlazy); + (void)d16; + double d17 = socket1.async_send_to(buffer(mutable_char_buffer), + ip::udp::endpoint(ip::udp::v6(), 0), in_flags, dlazy); + (void)d17; + double d18 = socket1.async_send_to(buffer(const_char_buffer), + ip::udp::endpoint(ip::udp::v4(), 0), in_flags, dlazy); + (void)d18; + double d19 = socket1.async_send_to(buffer(const_char_buffer), + ip::udp::endpoint(ip::udp::v6(), 0), in_flags, dlazy); + (void)d19; + double d20 = socket1.async_send_to(null_buffers(), + ip::udp::endpoint(ip::udp::v4(), 0), in_flags, dlazy); + (void)d20; + double d21 = socket1.async_send_to(null_buffers(), + ip::udp::endpoint(ip::udp::v6(), 0), in_flags, dlazy); + (void)d21; +#endif // !defined(ASIO_NO_DEPRECATED) socket1.receive(buffer(mutable_char_buffer)); socket1.receive(null_buffers()); @@ -395,6 +464,17 @@ void test() (void)i24; int i25 = socket1.async_receive(null_buffers(), in_flags, lazy); (void)i25; +#if !defined(ASIO_NO_DEPRECATED) + double d22 = socket1.async_receive(buffer(mutable_char_buffer), dlazy); + (void)d22; + double d23 = socket1.async_receive(null_buffers(), dlazy); + (void)d23; + double d24 = socket1.async_receive(buffer(mutable_char_buffer), + in_flags, dlazy); + (void)d24; + double d25 = socket1.async_receive(null_buffers(), in_flags, dlazy); + (void)d25; +#endif // !defined(ASIO_NO_DEPRECATED) ip::udp::endpoint endpoint; socket1.receive_from(buffer(mutable_char_buffer), endpoint); @@ -424,6 +504,20 @@ void test() int i29 = socket1.async_receive_from(null_buffers(), endpoint, in_flags, lazy); (void)i29; +#if !defined(ASIO_NO_DEPRECATED) + double d26 = socket1.async_receive_from(buffer(mutable_char_buffer), + endpoint, dlazy); + (void)d26; + double d27 = socket1.async_receive_from(null_buffers(), + endpoint, dlazy); + (void)d27; + double d28 = socket1.async_receive_from(buffer(mutable_char_buffer), + endpoint, in_flags, dlazy); + (void)d28; + double d29 = socket1.async_receive_from(null_buffers(), + endpoint, in_flags, dlazy); + (void)d29; +#endif // !defined(ASIO_NO_DEPRECATED) } catch (std::exception&) { @@ -533,6 +627,9 @@ void test() { io_context ioc; archetypes::lazy_handler lazy; +#if !defined(ASIO_NO_DEPRECATED) + archetypes::deprecated_lazy_handler dlazy; +#endif // !defined(ASIO_NO_DEPRECATED) asio::error_code ec; ip::udp::resolver::query q(ip::udp::v4(), "localhost", "0"); ip::udp::endpoint e(ip::address_v4::loopback(), 0); @@ -627,6 +724,34 @@ void test() resolver.async_resolve(e, resolve_handler()); int i6 = resolver.async_resolve(e, lazy); (void)i6; + +#if !defined(ASIO_NO_DEPRECATED) + resolver.async_resolve(q, resolve_handler()); + double d1 = resolver.async_resolve(q, dlazy); + (void)d1; + + resolver.async_resolve(q, resolve_handler()); + double d2 = resolver.async_resolve("", "", dlazy); + (void)d2; + + resolver.async_resolve(q, resolve_handler()); + double d3 = resolver.async_resolve("", "", + ip::udp::resolver::flags(), dlazy); + (void)d3; + + resolver.async_resolve(q, resolve_handler()); + double d4 = resolver.async_resolve(ip::udp::v4(), "", "", dlazy); + (void)d4; + + resolver.async_resolve(q, resolve_handler()); + double d5 = resolver.async_resolve(ip::udp::v4(), + "", "", ip::udp::resolver::flags(), dlazy); + (void)d5; + + resolver.async_resolve(e, resolve_handler()); + double d6 = resolver.async_resolve(e, dlazy); + (void)d6; +#endif // !defined(ASIO_NO_DEPRECATED) } catch (std::exception&) {