diff --git a/doc/Jamfile b/doc/Jamfile index b7c982d1e6..66c1d72eec 100644 --- a/doc/Jamfile +++ b/doc/Jamfile @@ -41,7 +41,7 @@ docca.reference reference.qbk \"BOOST_BEAST_ASYNC_RESULT2(t)=__deduced__\" \\ \"BOOST_BEAST_ASYNC_TPARAM1=class\" \\ \"BOOST_BEAST_ASYNC_TPARAM2=class\" \\ - \"BOOST_ASIO_INITFN_RESULT_TYPE(t,a)=__deduced__\" \\ + \"BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(t,a)=__deduced__\" \\ \"BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(e)= =__deduced__\" \\ \"BOOST_ASIO_COMPLETION_TOKEN_FOR(sig)=class\" \\ GENERATING_DOCUMENTATION \\ diff --git a/include/boost/beast/_experimental/test/impl/stream.hpp b/include/boost/beast/_experimental/test/impl/stream.hpp index 90dd625263..0971a5b007 100644 --- a/include/boost/beast/_experimental/test/impl/stream.hpp +++ b/include/boost/beast/_experimental/test/impl/stream.hpp @@ -31,11 +31,6 @@ template template class basic_stream::read_op : public detail::stream_read_op_base { - using ex1_type = - executor_type; - using ex2_type - = net::associated_executor_t; - struct lambda { Handler h_; @@ -44,7 +39,8 @@ class basic_stream::read_op : public detail::stream_read_op_base #if defined(BOOST_ASIO_NO_TS_EXECUTORS) net::any_io_executor wg2_; #else // defined(BOOST_ASIO_NO_TS_EXECUTORS) - net::executor_work_guard wg2_; + net::executor_work_guard< + net::associated_executor_t> wg2_; #endif // defined(BOOST_ASIO_NO_TS_EXECUTORS) lambda(lambda&&) = default; @@ -330,7 +326,7 @@ read_some(MutableBufferSequence const& buffers, template template -BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler, void(error_code, std::size_t)) +BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(ReadHandler, void(error_code, std::size_t)) basic_stream:: async_read_some( MutableBufferSequence const& buffers, @@ -414,7 +410,7 @@ write_some( template template -BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler, void(error_code, std::size_t)) +BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(WriteHandler, void(error_code, std::size_t)) basic_stream:: async_write_some( ConstBufferSequence const& buffers, diff --git a/include/boost/beast/_experimental/test/stream.hpp b/include/boost/beast/_experimental/test/stream.hpp index 0f9cc809ed..a3b0236150 100644 --- a/include/boost/beast/_experimental/test/stream.hpp +++ b/include/boost/beast/_experimental/test/stream.hpp @@ -468,7 +468,7 @@ class basic_stream class MutableBufferSequence, BOOST_ASIO_COMPLETION_TOKEN_FOR(void(error_code, std::size_t)) ReadHandler BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)> - BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler, void(error_code, std::size_t)) + BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(ReadHandler, void(error_code, std::size_t)) async_read_some( MutableBufferSequence const& buffers, ReadHandler&& handler BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)); @@ -547,7 +547,7 @@ class basic_stream class ConstBufferSequence, BOOST_ASIO_COMPLETION_TOKEN_FOR(void(error_code, std::size_t)) WriteHandler BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)> - BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler, void(error_code, std::size_t)) + BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(WriteHandler, void(error_code, std::size_t)) async_write_some( ConstBufferSequence const& buffers, WriteHandler&& handler BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type) diff --git a/include/boost/beast/core/basic_stream.hpp b/include/boost/beast/core/basic_stream.hpp index 19e9597464..2ba8f3a6a6 100644 --- a/include/boost/beast/core/basic_stream.hpp +++ b/include/boost/beast/core/basic_stream.hpp @@ -1022,7 +1022,7 @@ class basic_stream EndpointSequence>::value>::type #endif > - BOOST_ASIO_INITFN_RESULT_TYPE( + BOOST_ASIO_INITFN_AUTO_RESULT_TYPE( RangeConnectHandler, void(error_code, typename Protocol::endpoint)) async_connect( @@ -1126,7 +1126,7 @@ class basic_stream EndpointSequence>::value>::type #endif > - BOOST_ASIO_INITFN_RESULT_TYPE( + BOOST_ASIO_INITFN_AUTO_RESULT_TYPE( RangeConnectHandler, void(error_code, typename Protocol::endpoint)) async_connect( @@ -1195,7 +1195,7 @@ class basic_stream void(error_code, Iterator)) IteratorConnectHandler = net::default_completion_token_t> - BOOST_ASIO_INITFN_RESULT_TYPE( + BOOST_ASIO_INITFN_AUTO_RESULT_TYPE( IteratorConnectHandler, void(error_code, Iterator)) async_connect( @@ -1267,7 +1267,7 @@ class basic_stream void(error_code, Iterator)) IteratorConnectHandler = net::default_completion_token_t> - BOOST_ASIO_INITFN_RESULT_TYPE( + BOOST_ASIO_INITFN_AUTO_RESULT_TYPE( IteratorConnectHandler, void(error_code, Iterator)) async_connect( diff --git a/include/boost/beast/core/detect_ssl.hpp b/include/boost/beast/core/detect_ssl.hpp index b641b3ff2b..ea6c56f9c4 100644 --- a/include/boost/beast/core/detect_ssl.hpp +++ b/include/boost/beast/core/detect_ssl.hpp @@ -319,19 +319,12 @@ template< class CompletionToken = net::default_completion_token_t> > -#if BOOST_BEAST_DOXYGEN -BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, void(error_code, bool)) -#else -auto -#endif +BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, void(error_code, bool)) async_detect_ssl( AsyncReadStream& stream, DynamicBuffer& buffer, CompletionToken&& token = net::default_completion_token_t< - beast::executor_type>{}) -> - typename net::async_result< - typename std::decay::type, /*< `async_result` customizes the return value based on the completion token >*/ - void(error_code, bool)>::return_type; /*< This is the signature for the completion handler >*/ + beast::executor_type>{}); //] //[example_core_detect_ssl_5 @@ -395,18 +388,11 @@ template< class AsyncReadStream, class DynamicBuffer, class CompletionToken> -#if BOOST_BEAST_DOXYGEN -BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, void(error_code, bool)) -#else -auto -#endif +BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, void(error_code, bool)) async_detect_ssl( AsyncReadStream& stream, DynamicBuffer& buffer, CompletionToken&& token) - -> typename net::async_result< - typename std::decay::type, - void(error_code, bool)>::return_type { // Make sure arguments meet the type requirements diff --git a/include/boost/beast/core/impl/basic_stream.hpp b/include/boost/beast/core/impl/basic_stream.hpp index bb19d7873f..09337cded7 100644 --- a/include/boost/beast/core/impl/basic_stream.hpp +++ b/include/boost/beast/core/impl/basic_stream.hpp @@ -893,7 +893,7 @@ template< class EndpointSequence, BOOST_ASIO_COMPLETION_TOKEN_FOR(void(error_code, typename Protocol::endpoint)) RangeConnectHandler, class> -BOOST_ASIO_INITFN_RESULT_TYPE(RangeConnectHandler,void(error_code, typename Protocol::endpoint)) +BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(RangeConnectHandler,void(error_code, typename Protocol::endpoint)) basic_stream:: async_connect( EndpointSequence const& endpoints, @@ -915,7 +915,7 @@ template< class ConnectCondition, BOOST_ASIO_COMPLETION_TOKEN_FOR(void(error_code, typename Protocol::endpoint)) RangeConnectHandler, class> -BOOST_ASIO_INITFN_RESULT_TYPE(RangeConnectHandler,void (error_code, typename Protocol::endpoint)) +BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(RangeConnectHandler,void (error_code, typename Protocol::endpoint)) basic_stream:: async_connect( EndpointSequence const& endpoints, @@ -936,7 +936,7 @@ template template< class Iterator, BOOST_ASIO_COMPLETION_TOKEN_FOR(void(error_code, Iterator)) IteratorConnectHandler> -BOOST_ASIO_INITFN_RESULT_TYPE(IteratorConnectHandler,void (error_code, Iterator)) +BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(IteratorConnectHandler,void (error_code, Iterator)) basic_stream:: async_connect( Iterator begin, Iterator end, @@ -957,7 +957,7 @@ template< class Iterator, class ConnectCondition, BOOST_ASIO_COMPLETION_TOKEN_FOR(void(error_code, Iterator)) IteratorConnectHandler> -BOOST_ASIO_INITFN_RESULT_TYPE(IteratorConnectHandler,void (error_code, Iterator)) +BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(IteratorConnectHandler,void (error_code, Iterator)) basic_stream:: async_connect( Iterator begin, Iterator end, diff --git a/include/boost/beast/ssl/ssl_stream.hpp b/include/boost/beast/ssl/ssl_stream.hpp index 452320b722..ec7fea19b6 100644 --- a/include/boost/beast/ssl/ssl_stream.hpp +++ b/include/boost/beast/ssl/ssl_stream.hpp @@ -412,7 +412,7 @@ class ssl_stream ); @endcode */ template> - BOOST_ASIO_INITFN_RESULT_TYPE(HandshakeHandler, void(boost::system::error_code)) + BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(HandshakeHandler, void(boost::system::error_code)) async_handshake(handshake_type type, BOOST_ASIO_MOVE_ARG(HandshakeHandler) handler = net::default_completion_token_t{}) { @@ -443,7 +443,7 @@ class ssl_stream */ template> - BOOST_ASIO_INITFN_RESULT_TYPE(BufferedHandshakeHandler, void(boost::system::error_code, std::size_t)) + BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(BufferedHandshakeHandler, void(boost::system::error_code, std::size_t)) async_handshake(handshake_type type, ConstBufferSequence const& buffers, BOOST_ASIO_MOVE_ARG(BufferedHandshakeHandler) handler = net::default_completion_token_t{}) @@ -491,7 +491,7 @@ class ssl_stream ); @endcode */ template> - BOOST_ASIO_INITFN_RESULT_TYPE(ShutdownHandler, void(boost::system::error_code)) + BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(ShutdownHandler, void(boost::system::error_code)) async_shutdown(BOOST_ASIO_MOVE_ARG(ShutdownHandler) handler = net::default_completion_token_t{}) { return p_->next_layer().async_shutdown( @@ -570,7 +570,7 @@ class ssl_stream */ template> - BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler, void(boost::system::error_code, std::size_t)) + BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(WriteHandler, void(boost::system::error_code, std::size_t)) async_write_some(ConstBufferSequence const& buffers, BOOST_ASIO_MOVE_ARG(WriteHandler) handler= net::default_completion_token_t{}) { @@ -652,7 +652,7 @@ class ssl_stream */ template> - BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler, void(boost::system::error_code, std::size_t)) + BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(ReadHandler, void(boost::system::error_code, std::size_t)) async_read_some(MutableBufferSequence const& buffers, BOOST_ASIO_MOVE_ARG(ReadHandler) handler = net::default_completion_token_t{}) diff --git a/test/beast/core/basic_stream.cpp b/test/beast/core/basic_stream.cpp index 79406f9479..a74f491623 100644 --- a/test/beast/core/basic_stream.cpp +++ b/test/beast/core/basic_stream.cpp @@ -1298,7 +1298,7 @@ class basic_stream_test resolve_results.begin()->endpoint(), net::use_awaitable))>); - auto comparison_function = [](error_code&, net::ip::tcp::endpoint) { return true; }; + auto comparison_function = [](error_code const&, net::ip::tcp::endpoint) { return true; }; static_assert(std::is_same_v< net::awaitable, decltype( diff --git a/test/beast/http/CMakeLists.txt b/test/beast/http/CMakeLists.txt index 80af1e9c9c..cd4b49ec1c 100644 --- a/test/beast/http/CMakeLists.txt +++ b/test/beast/http/CMakeLists.txt @@ -23,6 +23,7 @@ add_executable (tests-beast-http basic_parser.cpp buffer_body.cpp chunk_encode.cpp + deferred.cpp dynamic_body.cpp empty_body.cpp error.cpp diff --git a/test/beast/http/Jamfile b/test/beast/http/Jamfile index 6e1e564f31..487be1abbf 100644 --- a/test/beast/http/Jamfile +++ b/test/beast/http/Jamfile @@ -14,6 +14,7 @@ local SOURCES = basic_parser.cpp buffer_body.cpp chunk_encode.cpp + deferred.cpp dynamic_body.cpp error.cpp field.cpp diff --git a/test/beast/http/deferred.cpp b/test/beast/http/deferred.cpp new file mode 100644 index 0000000000..c0d67040d8 --- /dev/null +++ b/test/beast/http/deferred.cpp @@ -0,0 +1,36 @@ +// +// Copyright (c) 2023 Mohammad Nejati +// +// 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) +// + +#include +#include +#include + +using namespace boost; +namespace http = boost::beast::http; + +#if !defined(BOOST_NO_CXX14) + +// just compile this. +void test_deferred_for_http( + asio::ip::tcp::socket & stream, + beast::flat_static_buffer_base & buf, + http::basic_parser & parser, + http::serializer & ser, + http::message & msg) +{ + http::async_read(stream, buf, parser, asio::deferred); + http::async_read(stream, buf, msg, asio::deferred); + http::async_read_some(stream, buf, parser, asio::deferred); + http::async_read_header(stream, buf, parser, asio::deferred); + + http::async_write(stream, ser, asio::deferred); + http::async_write(stream, msg, asio::deferred); + http::async_write_header(stream, ser, asio::deferred); + http::async_write_some(stream, ser, asio::deferred); +} + +#endif diff --git a/test/beast/websocket/CMakeLists.txt b/test/beast/websocket/CMakeLists.txt index 0df8f74f77..3610c9b169 100644 --- a/test/beast/websocket/CMakeLists.txt +++ b/test/beast/websocket/CMakeLists.txt @@ -24,6 +24,7 @@ add_executable (tests-beast-websocket accept.cpp cancel.cpp close.cpp + deferred.cpp error.cpp frame.cpp handshake.cpp diff --git a/test/beast/websocket/Jamfile b/test/beast/websocket/Jamfile index 3db37042e4..eddc9f73fe 100644 --- a/test/beast/websocket/Jamfile +++ b/test/beast/websocket/Jamfile @@ -15,6 +15,7 @@ local SOURCES = accept.cpp cancel.cpp close.cpp + deferred.cpp error.cpp frame.cpp handshake.cpp diff --git a/test/beast/websocket/deferred.cpp b/test/beast/websocket/deferred.cpp new file mode 100644 index 0000000000..cffe4f08f6 --- /dev/null +++ b/test/beast/websocket/deferred.cpp @@ -0,0 +1,43 @@ +// +// Copyright (c) 2023 Mohammad Nejati +// +// 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) +// + +#include +#include +#include + +using namespace boost; +namespace websocket = boost::beast::websocket; + +#if !defined(BOOST_NO_CXX14) + +// just compile this. +void test_deferred_for_websocket( + websocket::stream & stream, + beast::flat_static_buffer_base & buf, + beast::http::request & req, + websocket::response_type & res) +{ + stream.async_accept(asio::deferred); + stream.async_accept(asio::const_buffer(), asio::deferred); + stream.async_accept(req, asio::deferred); + stream.async_close(websocket::close_code::bad_payload, asio::deferred); + + stream.async_handshake("", "/", asio::deferred); + stream.async_handshake(res, "", "/", asio::deferred); + + stream.async_ping(websocket::ping_data{}, asio::deferred); + stream.async_pong(websocket::ping_data{}, asio::deferred); + + stream.async_read(buf, asio::deferred); + stream.async_read_some(buf.data(), asio::deferred); + + stream.async_write(buf.cdata(), asio::deferred); + stream.async_write_some(true, buf.cdata(), asio::deferred); + +} + +#endif