diff --git a/doc/qbk/03_core/7_composed.qbk b/doc/qbk/03_core/7_composed.qbk index 1a9b6134..c59a50b8 100644 --- a/doc/qbk/03_core/7_composed.qbk +++ b/doc/qbk/03_core/7_composed.qbk @@ -50,8 +50,8 @@ composed operations: This class is designed to be used as a base class when authoring composed asynchronous operations expressed as an intermediate completion handler. This eliminates the need for the extensive - boilerplate to propagate the associated executor, associated - allocator, and legacy completion handler hooks. + boilerplate to propagate the associated executor and the associated + allocator. ]] [[ [link beast.ref.boost__beast__allocate_stable `allocate_stable`] diff --git a/doc/qbk/03_core/7a_echo.qbk b/doc/qbk/03_core/7a_echo.qbk index 698e6cf2..a5f75d05 100644 --- a/doc/qbk/03_core/7a_echo.qbk +++ b/doc/qbk/03_core/7a_echo.qbk @@ -34,7 +34,7 @@ The implementation strategy is to make the composed object meet the requirements of a completion handler by being movable, and by making it invocable so it can be used as a continuation for the asynchronous operations it launches. Rather than using `std::bind` or `boost::bind`, which destroys -the type information and therefore breaks the allocation and invocation hooks, +the type information and therefore breaks the associators, we will simply pass `std::move(*this)` as the completion handler parameter for any operations that we initiate. For the move to work correctly, care must be taken to ensure that no access to data members are made after the move takes diff --git a/doc/qbk/08_design/3_websocket_zaphoyd.qbk b/doc/qbk/08_design/3_websocket_zaphoyd.qbk index 2f5d1f37..364b208b 100644 --- a/doc/qbk/08_design/3_websocket_zaphoyd.qbk +++ b/doc/qbk/08_design/3_websocket_zaphoyd.qbk @@ -118,7 +118,7 @@ access. In contrast, Beast does not use mutexes anywhere in its implementation. Instead, it follows the Asio pattern. Calls to asynchronous initiation functions use the same method to invoke intermediate handlers as the method used to invoke the final handler, -through the __asio_handler_invoke__ mechanism. +through the associated executor mechanism. The only requirement in Beast is that calls to asynchronous initiation functions are made from the same implicit or explicit strand. For @@ -131,14 +131,6 @@ costs associated with mutexes are incurred. [[@https://github.com/vinniefalco/Beast/blob/6c8b4b2f8dde72b01507e4ac7fde4ffea57ebc99/include/beast/websocket/impl/read_frame_op.ipp#L118 Beast]] [[@https://github.com/zaphoyd/websocketpp/blob/378437aecdcb1dfe62096ffd5d944bf1f640ccc3/websocketpp/transport/iostream/connection.hpp#L706 websocketpp]] ][ - [``` - template - friend - void asio_handler_invoke(Function&& f, read_frame_op* op) - { - return boost_asio_handler_invoke_helpers::invoke(f, op->d_->h); - } - ```] [``` mutex_type m_read_mutex; ```] @@ -156,9 +148,9 @@ Boost.Asio. They are function objects which can be copied or moved but most importantly they are not type erased. The compiler can see through the type directly to the implementation, permitting optimization. Furthermore, Beast follows the Asio rules for treatment -of handlers. It respects any allocation, continuation, or invocation -customizations associated with the handler through the use of argument -dependent lookup overloads of functions such as `asio_handler_allocate`. +of handlers. It respects any allocation, executors, cancellations +associated with the handler through the use of argument +dependent lookup overloads of functions such as `bind_allocaotr`. The Beast completion handler is provided at the call site. For each call to an asynchronous initiation function, it is guaranteed that diff --git a/doc/qbk/main.qbk b/doc/qbk/main.qbk index 84a5203b..778bd44f 100644 --- a/doc/qbk/main.qbk +++ b/doc/qbk/main.qbk @@ -43,8 +43,6 @@ [/ Networking Identifiers ] -[def __asio_handler_allocate__ [@boost:/doc/html/boost_asio/reference/asio_handler_allocate.html `asio_handler_allocate`]] -[def __asio_handler_invoke__ [@boost:/doc/html/boost_asio/reference/asio_handler_invoke.html `asio_handler_invoke`]] [def __basic_stream_socket__ [@boost:/doc/html/boost_asio/reference/basic_stream_socket.html `basic_stream_socket`]] [def __const_buffer__ [@boost:/doc/html/boost_asio/reference/const_buffer.html `const_buffer`]] [def __deduced__ [@boost:/doc/html/boost_asio/reference/asynchronous_operations.html#boost_asio.reference.asynchronous_operations.automatic_deduction_of_initiating_function_return_type ['DEDUCED]]] diff --git a/doc/qbk/release_notes.qbk b/doc/qbk/release_notes.qbk index d5f2958d..ff2eb8ef 100644 --- a/doc/qbk/release_notes.qbk +++ b/doc/qbk/release_notes.qbk @@ -196,7 +196,7 @@ * The API to Asio has undergone changes. Please refer to the Asio release notes for details. * Beast has been updated to track and respect developer choices in the use of Asio. In particular: - * Define `BOOST_ASIO_NO_DEPRECATED` to disallow deprecated invocation and allocation hooks. + * Define `BOOST_ASIO_NO_DEPRECATED` to disallow deprecated invocation hooks. * Define `BOOST_ASIO_NO_TS_EXECUTORS` to ensure that executors conform to the [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0443r11.html Standard Executors] proposal. * Define `BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT` to select diff --git a/include/boost/beast/core/async_base.hpp b/include/boost/beast/core/async_base.hpp index cd185189..d8fe12ec 100644 --- a/include/boost/beast/core/async_base.hpp +++ b/include/boost/beast/core/async_base.hpp @@ -20,9 +20,7 @@ #include #include #include -#include #include -#include #include #include #include @@ -63,11 +61,7 @@ namespace beast { shall be maintained until either the final handler is invoked, or the operation base is destroyed, whichever comes first. - @li Calls to the legacy customization points - `asio_handler_invoke`, - `asio_handler_allocate`, - `asio_handler_deallocate`, and - `asio_handler_is_continuation`, + @li Calls to the legacy customization point `asio_handler_is_continuation` which use argument-dependent lookup, will be forwarded to the legacy customization points associated with the handler. @@ -506,13 +500,6 @@ public: shall be maintained until either the final handler is invoked, or the operation base is destroyed, whichever comes first. - @li Calls to the legacy customization points - `asio_handler_invoke`, - `asio_handler_allocate`, - `asio_handler_deallocate`, and - `asio_handler_is_continuation`, - which use argument-dependent lookup, will be forwarded to the - legacy customization points associated with the handler. Data members of composed operations implemented as completion handlers do not have stable addresses, as the composed operation object is move diff --git a/include/boost/beast/core/detail/bind_default_executor.hpp b/include/boost/beast/core/detail/bind_default_executor.hpp index 9dd050a1..0da3db32 100644 --- a/include/boost/beast/core/detail/bind_default_executor.hpp +++ b/include/boost/beast/core/detail/bind_default_executor.hpp @@ -77,31 +77,6 @@ public: net::cancellation_slot()); } - // The allocation hooks are still defined because they trivially forward to - // user hooks. Forward here ensures that the user will get a compile error - // if they build their code with BOOST_ASIO_NO_DEPRECATED. - - friend - boost::asio::asio_handler_allocate_is_deprecated - asio_handler_allocate( - std::size_t size, bind_default_executor_wrapper* p) - { - using boost::asio::asio_handler_allocate; - return asio_handler_allocate( - size, std::addressof(p->h_)); - } - - friend - boost::asio::asio_handler_deallocate_is_deprecated - asio_handler_deallocate( - void* mem, std::size_t size, - bind_default_executor_wrapper* p) - { - using boost::asio::asio_handler_deallocate; - return asio_handler_deallocate(mem, size, - std::addressof(p->h_)); - } - friend bool asio_handler_is_continuation( bind_default_executor_wrapper* p) diff --git a/include/boost/beast/core/detail/bind_handler.hpp b/include/boost/beast/core/detail/bind_handler.hpp index 8d5c5bbb..4b1d188d 100644 --- a/include/boost/beast/core/detail/bind_handler.hpp +++ b/include/boost/beast/core/detail/bind_handler.hpp @@ -15,9 +15,7 @@ #include #include #include -#include #include -#include #include #include #include @@ -160,16 +158,6 @@ public: // - template - friend - boost::asio::asio_handler_invoke_is_deprecated - asio_handler_invoke( - Function&& f, bind_wrapper* op) - { - using boost::asio::asio_handler_invoke; - return asio_handler_invoke(f, std::addressof(op->h_)); - } - friend bool asio_handler_is_continuation( bind_wrapper* op) @@ -178,26 +166,6 @@ public: return asio_handler_is_continuation( std::addressof(op->h_)); } - - friend - boost::asio::asio_handler_allocate_is_deprecated - asio_handler_allocate( - std::size_t size, bind_wrapper* op) - { - using boost::asio::asio_handler_allocate; - return asio_handler_allocate( - size, std::addressof(op->h_)); - } - - friend - boost::asio::asio_handler_deallocate_is_deprecated - asio_handler_deallocate( - void* p, std::size_t size, bind_wrapper* op) - { - using boost::asio::asio_handler_deallocate; - return asio_handler_deallocate( - p, size, std::addressof(op->h_)); - } }; template @@ -277,16 +245,6 @@ public: // - template - friend - boost::asio::asio_handler_invoke_is_deprecated - asio_handler_invoke( - Function&& f, bind_front_wrapper* op) - { - using boost::asio::asio_handler_invoke; - return asio_handler_invoke(f, std::addressof(op->h_)); - } - friend bool asio_handler_is_continuation( bind_front_wrapper* op) @@ -295,26 +253,6 @@ public: return asio_handler_is_continuation( std::addressof(op->h_)); } - - friend - boost::asio::asio_handler_allocate_is_deprecated - asio_handler_allocate( - std::size_t size, bind_front_wrapper* op) - { - using boost::asio::asio_handler_allocate; - return asio_handler_allocate( - size, std::addressof(op->h_)); - } - - friend - boost::asio::asio_handler_deallocate_is_deprecated - asio_handler_deallocate( - void* p, std::size_t size, bind_front_wrapper* op) - { - using boost::asio::asio_handler_deallocate; - return asio_handler_deallocate( - p, size, std::addressof(op->h_)); - } }; } // detail diff --git a/include/boost/beast/core/impl/async_base.hpp b/include/boost/beast/core/impl/async_base.hpp index 1f9dc8b5..40f411e1 100644 --- a/include/boost/beast/core/impl/async_base.hpp +++ b/include/boost/beast/core/impl/async_base.hpp @@ -50,48 +50,6 @@ struct allocate_stable_state final } // detail -template< - class Handler, - class Executor1, - class Allocator, - class Function> -boost::asio::asio_handler_invoke_is_deprecated -asio_handler_invoke( - Function&& f, - async_base* p) -{ - using boost::asio::asio_handler_invoke; - return asio_handler_invoke(f, - p->get_legacy_handler_pointer()); -} - -template< - class Handler, - class Executor1, - class Allocator> -boost::asio::asio_handler_allocate_is_deprecated -asio_handler_allocate( - std::size_t size, - async_base* p) -{ - using boost::asio::asio_handler_allocate; - return asio_handler_allocate(size, - p->get_legacy_handler_pointer()); -} - -template< - class Handler, - class Executor1, - class Allocator> -boost::asio::asio_handler_deallocate_is_deprecated -asio_handler_deallocate( - void* mem, std::size_t size, - async_base* p) -{ - using boost::asio::asio_handler_deallocate; - return asio_handler_deallocate(mem, size, - p->get_legacy_handler_pointer()); -} template< class Handler, diff --git a/test/beast/core/test_handler.hpp b/test/beast/core/test_handler.hpp index de7bb4e9..88e667d4 100644 --- a/test/beast/core/test_handler.hpp +++ b/test/beast/core/test_handler.hpp @@ -14,9 +14,7 @@ #include #include #include -#include #include -#include namespace boost { namespace beast { @@ -128,33 +126,6 @@ struct legacy_handler test(F const& f) { #if !defined(BOOST_ASIO_NO_DEPRECATED) - { - bool hook_invoked = false; - bool lambda_invoked = false; - auto h = f(legacy_handler{hook_invoked}); - using net::asio_handler_invoke; - asio_handler_invoke( - [&lambda_invoked] - { - lambda_invoked =true; - }, &h); - BEAST_EXPECT(hook_invoked); - BEAST_EXPECT(lambda_invoked); - } - { - bool hook_invoked = false; - auto h = f(legacy_handler{hook_invoked}); - using net::asio_handler_allocate; - asio_handler_allocate(0, &h); - BEAST_EXPECT(hook_invoked); - } - { - bool hook_invoked = false; - auto h = f(legacy_handler{hook_invoked}); - using net::asio_handler_deallocate; - asio_handler_deallocate(nullptr, 0, &h); - BEAST_EXPECT(hook_invoked); - } { bool hook_invoked = false; auto h = f(legacy_handler{hook_invoked}); @@ -168,35 +139,6 @@ struct legacy_handler } }; -template -void -asio_handler_invoke( - Function&& f, - legacy_handler* p) -{ - p->hook_invoked = true; - f(); -} - -inline -void* -asio_handler_allocate( - std::size_t, - legacy_handler* p) -{ - p->hook_invoked = true; - return nullptr; -} - -inline -void -asio_handler_deallocate( - void*, std::size_t, - legacy_handler* p) -{ - p->hook_invoked = true; -} - inline bool asio_handler_is_continuation(