From 22f2f5dcf4a088733d9e76dae2985874a1239112 Mon Sep 17 00:00:00 2001 From: Christopher Kohlhoff Date: Tue, 23 Jun 2020 09:49:17 +1000 Subject: [PATCH] Handler invoke and allocation hooks are deprecated --- CHANGELOG.md | 4 ++ .../core/detail/bind_default_executor.hpp | 23 +++++++--- .../boost/beast/core/detail/bind_handler.hpp | 42 +++++++++++-------- include/boost/beast/core/impl/async_base.hpp | 19 +++++---- 4 files changed, 55 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ec018df..db7ba1fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +* Handler invoke and allocation hooks are deprecated. + +-------------------------------------------------------------------------------- + Version 297: * iless and iequal take part in Heterogeneous Lookup diff --git a/include/boost/beast/core/detail/bind_default_executor.hpp b/include/boost/beast/core/detail/bind_default_executor.hpp index 6fa006e1..095d8bf3 100644 --- a/include/boost/beast/core/detail/bind_default_executor.hpp +++ b/include/boost/beast/core/detail/bind_default_executor.hpp @@ -67,6 +67,10 @@ public: h_, this->get()); } + // The invocation hook is no longer defined because it customises behaviour + // without forwarding to a user's hook. + +#if 0 template void asio_handler_invoke(Function&& f, @@ -74,23 +78,30 @@ public: { net::dispatch(p->get_executor(), std::move(f)); } +#endif + + // 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 - void* asio_handler_allocate( + boost::asio::asio_handler_allocate_is_deprecated + asio_handler_allocate( std::size_t size, bind_default_executor_wrapper* p) { - using net::asio_handler_allocate; + using boost::asio::asio_handler_allocate; return asio_handler_allocate( size, std::addressof(p->h_)); } friend - void asio_handler_deallocate( + boost::asio::asio_handler_deallocate_is_deprecated + asio_handler_deallocate( void* mem, std::size_t size, bind_default_executor_wrapper* p) { - using net::asio_handler_deallocate; - asio_handler_deallocate(mem, size, + using boost::asio::asio_handler_deallocate; + return asio_handler_deallocate(mem, size, std::addressof(p->h_)); } @@ -98,7 +109,7 @@ public: bool asio_handler_is_continuation( bind_default_executor_wrapper* p) { - using net::asio_handler_is_continuation; + using boost::asio::asio_handler_is_continuation; return asio_handler_is_continuation( std::addressof(p->h_)); } diff --git a/include/boost/beast/core/detail/bind_handler.hpp b/include/boost/beast/core/detail/bind_handler.hpp index db481757..07db8d4b 100644 --- a/include/boost/beast/core/detail/bind_handler.hpp +++ b/include/boost/beast/core/detail/bind_handler.hpp @@ -155,37 +155,40 @@ public: template friend - void asio_handler_invoke( + boost::asio::asio_handler_invoke_is_deprecated + asio_handler_invoke( Function&& f, bind_wrapper* op) { - using net::asio_handler_invoke; - asio_handler_invoke(f, std::addressof(op->h_)); + using boost::asio::asio_handler_invoke; + return asio_handler_invoke(f, std::addressof(op->h_)); } friend bool asio_handler_is_continuation( bind_wrapper* op) { - using net::asio_handler_is_continuation; + using boost::asio::asio_handler_is_continuation; return asio_handler_is_continuation( std::addressof(op->h_)); } friend - void* asio_handler_allocate( + boost::asio::asio_handler_allocate_is_deprecated + asio_handler_allocate( std::size_t size, bind_wrapper* op) { - using net::asio_handler_allocate; + using boost::asio::asio_handler_allocate; return asio_handler_allocate( size, std::addressof(op->h_)); } friend - void asio_handler_deallocate( + boost::asio::asio_handler_deallocate_is_deprecated + asio_handler_deallocate( void* p, std::size_t size, bind_wrapper* op) { - using net::asio_handler_deallocate; - asio_handler_deallocate( + using boost::asio::asio_handler_deallocate; + return asio_handler_deallocate( p, size, std::addressof(op->h_)); } }; @@ -265,37 +268,40 @@ public: template friend - void asio_handler_invoke( + boost::asio::asio_handler_invoke_is_deprecated + asio_handler_invoke( Function&& f, bind_front_wrapper* op) { - using net::asio_handler_invoke; - asio_handler_invoke(f, std::addressof(op->h_)); + 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) { - using net::asio_handler_is_continuation; + using boost::asio::asio_handler_is_continuation; return asio_handler_is_continuation( std::addressof(op->h_)); } friend - void* asio_handler_allocate( + boost::asio::asio_handler_allocate_is_deprecated + asio_handler_allocate( std::size_t size, bind_front_wrapper* op) { - using net::asio_handler_allocate; + using boost::asio::asio_handler_allocate; return asio_handler_allocate( size, std::addressof(op->h_)); } friend - void asio_handler_deallocate( + boost::asio::asio_handler_deallocate_is_deprecated + asio_handler_deallocate( void* p, std::size_t size, bind_front_wrapper* op) { - using net::asio_handler_deallocate; - asio_handler_deallocate( + using boost::asio::asio_handler_deallocate; + return asio_handler_deallocate( p, size, std::addressof(op->h_)); } }; diff --git a/include/boost/beast/core/impl/async_base.hpp b/include/boost/beast/core/impl/async_base.hpp index 8dc8cb29..1f9dc8b5 100644 --- a/include/boost/beast/core/impl/async_base.hpp +++ b/include/boost/beast/core/impl/async_base.hpp @@ -55,12 +55,13 @@ template< class Executor1, class Allocator, class Function> -void asio_handler_invoke( +boost::asio::asio_handler_invoke_is_deprecated +asio_handler_invoke( Function&& f, async_base* p) { - using net::asio_handler_invoke; - asio_handler_invoke(f, + using boost::asio::asio_handler_invoke; + return asio_handler_invoke(f, p->get_legacy_handler_pointer()); } @@ -68,12 +69,12 @@ template< class Handler, class Executor1, class Allocator> -void* +boost::asio::asio_handler_allocate_is_deprecated asio_handler_allocate( std::size_t size, async_base* p) { - using net::asio_handler_allocate; + using boost::asio::asio_handler_allocate; return asio_handler_allocate(size, p->get_legacy_handler_pointer()); } @@ -82,13 +83,13 @@ template< class Handler, class Executor1, class Allocator> -void +boost::asio::asio_handler_deallocate_is_deprecated asio_handler_deallocate( void* mem, std::size_t size, async_base* p) { - using net::asio_handler_deallocate; - asio_handler_deallocate(mem, size, + using boost::asio::asio_handler_deallocate; + return asio_handler_deallocate(mem, size, p->get_legacy_handler_pointer()); } @@ -100,7 +101,7 @@ bool asio_handler_is_continuation( async_base* p) { - using net::asio_handler_is_continuation; + using boost::asio::asio_handler_is_continuation; return asio_handler_is_continuation( p->get_legacy_handler_pointer()); }