diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e3adfd8..7805e261 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,8 +13,8 @@ API Changes * Return http::error::end_of_stream on HTTP read eof * Remove placeholders -* Move prepare_buffers to prepare_buffer.hpp * Rename prepare_buffer(s) to buffer_prefix +* Remove handler helpers, tidy up hook invocations -------------------------------------------------------------------------------- diff --git a/doc/core.qbk b/doc/core.qbk index 40cd6f93..6b87f211 100644 --- a/doc/core.qbk +++ b/doc/core.qbk @@ -294,53 +294,6 @@ the associated asynchronous initiation functions used to launch them. ]] ] -When implementing composed operations it is necessary to provide hooks for -the composed operation which forward the hook calls to the hooks associated -with the final completion handler. These calls must be made from a namespace -that does not include overloads of the hook functions, since they depend on -argument dependent lookup to resolve. Beast provides a set of public helper -functions to invoke these hooks. These hooks are all located in the -`beast_asio_helpers` namespace rather than the `beast` namespace: - -[table Handler Hooks -[[Name][Description]] -[[ - [link beast.ref.beast_asio_helpers__allocate `allocate`] -][ - Allocation function for a handler. Asynchronous operations may need to - allocate temporary objects. Since asynchronous operations have a handler - function object, these temporary objects can be said to be associated with - the handler. -]] -[[ - [link beast.ref.beast_asio_helpers__deallocate `deallocate`] -][ - Deallocation function for a handler. The implementation guarantees that - the deallocation will occur before the associated handler is invoked, which - means the memory is ready to be reused for any new asynchronous operations - started by the handler. -]] -[[ - [link beast.ref.beast_asio_helpers__invoke `invoke`] -][ - Invocation function for a handler. When asynchronous operations are - composed from other asynchronous operations, all intermediate handlers - should be invoked using the same method as the final handler. This is - required to ensure that user-defined objects are not accessed in a way - that may violate the guarantees. This hooking function ensures that the - invoked method used for the final handler is accessible at each - intermediate step. -]] -[[ - [link beast.ref.beast_asio_helpers__is_continuation `is_continuation`] -][ - Continuation function for a handler. Asynchronous operations may represent - a continuation of the asynchronous control flow associated with the current - handler. The implementation can use this knowledge to optimise scheduling - of the handler. -]] -] - [endsect] diff --git a/doc/quickref.xml b/doc/quickref.xml index 41d508f8..d99617dd 100644 --- a/doc/quickref.xml +++ b/doc/quickref.xml @@ -207,13 +207,6 @@ - Helpers - - allocate - deallocate - invoke - is_continuation - Concepts AsyncStream diff --git a/examples/http_async_server.hpp b/examples/http_async_server.hpp index 5506603e..9d359232 100644 --- a/examples/http_async_server.hpp +++ b/examples/http_async_server.hpp @@ -12,7 +12,6 @@ #include "mime_type.hpp" #include -#include #include #include #include @@ -98,11 +97,11 @@ private: data(Handler& handler, Stream& s_, message&& m_) - : cont(beast_asio_helpers:: - is_continuation(handler)) - , s(s_) + : s(s_) , m(std::move(m_)) { + using boost::asio::asio_handler_is_continuation; + cont = asio_handler_is_continuation(std::addressof(handler)); } }; @@ -137,16 +136,18 @@ private: void* asio_handler_allocate( std::size_t size, write_op* op) { - return beast_asio_helpers:: - allocate(size, op->d_.handler()); + using boost::asio::asio_handler_allocate; + return asio_handler_allocate( + size, std::addressof(op->d_.handler())); } friend void asio_handler_deallocate( void* p, std::size_t size, write_op* op) { - return beast_asio_helpers:: - deallocate(p, size, op->d_.handler()); + using boost::asio::asio_handler_deallocate; + asio_handler_deallocate( + p, size, std::addressof(op->d_.handler())); } friend @@ -159,8 +160,9 @@ private: friend void asio_handler_invoke(Function&& f, write_op* op) { - return beast_asio_helpers:: - invoke(f, op->d_.handler()); + using boost::asio::asio_handler_invoke; + asio_handler_invoke( + f, std::addressof(op->d_.handler())); } }; diff --git a/include/beast/core.hpp b/include/beast/core.hpp index 5770e6fa..214c9f33 100644 --- a/include/beast/core.hpp +++ b/include/beast/core.hpp @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include diff --git a/include/beast/core/detail/bind_handler.hpp b/include/beast/core/detail/bind_handler.hpp index d3cc3cdc..ad9f4e48 100644 --- a/include/beast/core/detail/bind_handler.hpp +++ b/include/beast/core/detail/bind_handler.hpp @@ -8,8 +8,10 @@ #ifndef BEAST_BIND_DETAIL_HANDLER_HPP #define BEAST_BIND_DETAIL_HANDLER_HPP -#include #include +#include +#include +#include #include namespace beast { @@ -68,8 +70,9 @@ public: asio_handler_allocate( std::size_t size, bound_handler* h) { - return beast_asio_helpers:: - allocate(size, h->h_); + using boost::asio::asio_handler_allocate; + return asio_handler_allocate( + size, std::addressof(h->h_)); } friend @@ -77,16 +80,17 @@ public: asio_handler_deallocate( void* p, std::size_t size, bound_handler* h) { - beast_asio_helpers:: - deallocate(p, size, h->h_); + using boost::asio::asio_handler_deallocate; + asio_handler_deallocate( + p, size, std::addressof(h->h_)); } friend bool asio_handler_is_continuation(bound_handler* h) { - return beast_asio_helpers:: - is_continuation (h->h_); + using boost::asio::asio_handler_is_continuation; + return asio_handler_is_continuation(std::addressof(h->h_)); } template @@ -94,8 +98,9 @@ public: void asio_handler_invoke(F&& f, bound_handler* h) { - beast_asio_helpers:: - invoke(f, h->h_); + using boost::asio::asio_handler_invoke; + asio_handler_invoke( + f, std::addressof(h->h_)); } }; diff --git a/include/beast/core/handler_alloc.hpp b/include/beast/core/handler_alloc.hpp index b110ec44..766f6fcd 100644 --- a/include/beast/core/handler_alloc.hpp +++ b/include/beast/core/handler_alloc.hpp @@ -9,7 +9,7 @@ #define BEAST_HANDLER_ALLOC_HPP #include -#include +#include #include #include #include @@ -92,17 +92,17 @@ public: allocate(std::ptrdiff_t n) { auto const size = n * sizeof(T); + using boost::asio::asio_handler_allocate; return static_cast( - beast_asio_helpers::allocate( - size, h_)); + asio_handler_allocate(size, std::addressof(h_))); } void deallocate(value_type* p, std::ptrdiff_t n) { auto const size = n * sizeof(T); - beast_asio_helpers::deallocate( - p, size, h_); + using boost::asio::asio_handler_deallocate; + asio_handler_deallocate(p, size, std::addressof(h_)); } #ifdef _MSC_VER diff --git a/include/beast/core/handler_helpers.hpp b/include/beast/core/handler_helpers.hpp deleted file mode 100644 index 53112e7f..00000000 --- a/include/beast/core/handler_helpers.hpp +++ /dev/null @@ -1,105 +0,0 @@ -// -// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail 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 BEAST_HANDLER_HELPERS_HPP -#define BEAST_HANDLER_HELPERS_HPP - -#include -#include -#include -#include -#include - -/* Calls to: - - * asio_handler_allocate - * asio_handler_deallocate - * asio_handler_invoke - * asio_handler_is_continuation - - must be made from a namespace that does not - contain overloads of this function. The beast_asio_helpers - namespace is defined here for that purpose. -*/ - -namespace beast_asio_helpers { - -/// Allocation function for handlers. -template -inline -void* -allocate(std::size_t s, Handler& handler) -{ -#if !defined(BOOST_ASIO_HAS_HANDLER_HOOKS) - return ::operator new(s); -#else - using boost::asio::asio_handler_allocate; - return asio_handler_allocate(s, std::addressof(handler)); -#endif -} - -/// Deallocation function for handlers. -template -inline -void -deallocate(void* p, std::size_t s, Handler& handler) -{ -#if !defined(BOOST_ASIO_HAS_HANDLER_HOOKS) - ::operator delete(p); -#else - using boost::asio::asio_handler_deallocate; - asio_handler_deallocate(p, s, std::addressof(handler)); -#endif -} - -/// Invoke function for handlers. -template -inline -void -invoke(Function& function, Handler& handler) -{ -#if !defined(BOOST_ASIO_HAS_HANDLER_HOOKS) - Function tmp(function); - tmp(); -#else - using boost::asio::asio_handler_invoke; - asio_handler_invoke(function, std::addressof(handler)); -#endif -} - -/// Invoke function for handlers. -template -inline -void -invoke(Function const& function, Handler& handler) -{ -#if !defined(BOOST_ASIO_HAS_HANDLER_HOOKS) - Function tmp(function); - tmp(); -#else - using boost::asio::asio_handler_invoke; - asio_handler_invoke(function, std::addressof(handler)); -#endif -} - -/// Returns true if handler represents a continuation of the asynchronous operation -template -inline -bool -is_continuation(Handler& handler) -{ -#if !defined(BOOST_ASIO_HAS_HANDLER_HOOKS) - return false; -#else - using boost::asio::asio_handler_is_continuation; - return asio_handler_is_continuation(std::addressof(handler)); -#endif -} - -} // beast_asio_helpers - -#endif diff --git a/include/beast/core/impl/buffered_read_stream.ipp b/include/beast/core/impl/buffered_read_stream.ipp index 4e00b240..64cc4da7 100644 --- a/include/beast/core/impl/buffered_read_stream.ipp +++ b/include/beast/core/impl/buffered_read_stream.ipp @@ -10,9 +10,11 @@ #include #include -#include #include #include +#include +#include +#include namespace beast { @@ -59,31 +61,35 @@ public: void* asio_handler_allocate( std::size_t size, read_some_op* op) { - return beast_asio_helpers:: - allocate(size, op->d_.handler()); + using boost::asio::asio_handler_allocate; + return asio_handler_allocate( + size, std::addressof(op->d_.handler())); } friend void asio_handler_deallocate( void* p, std::size_t size, read_some_op* op) { - return beast_asio_helpers:: - deallocate(p, size, op->d_.handler()); + using boost::asio::asio_handler_deallocate; + asio_handler_deallocate( + p, size, std::addressof(op->d_.handler())); } friend bool asio_handler_is_continuation(read_some_op* op) { - return beast_asio_helpers:: - is_continuation(op->d_.handler()); + using boost::asio::asio_handler_is_continuation; + return asio_handler_is_continuation( + std::addressof(op->d_.handler())); } template friend void asio_handler_invoke(Function&& f, read_some_op* op) { - return beast_asio_helpers:: - invoke(f, op->d_.handler()); + using boost::asio::asio_handler_invoke; + asio_handler_invoke( + f, std::addressof(op->d_.handler())); } }; diff --git a/include/beast/core/impl/handler_ptr.ipp b/include/beast/core/impl/handler_ptr.ipp index 2243d5df..82574de6 100644 --- a/include/beast/core/impl/handler_ptr.ipp +++ b/include/beast/core/impl/handler_ptr.ipp @@ -8,8 +8,9 @@ #ifndef BEAST_IMPL_HANDLER_PTR_HPP #define BEAST_IMPL_HANDLER_PTR_HPP -#include -#include +#include +#include +#include #include #include @@ -23,9 +24,10 @@ P(DeducedHandler&& h, Args&&... args) : n(1) , handler(std::forward(h)) { + using boost::asio::asio_handler_allocate; t = reinterpret_cast( - beast_asio_helpers:: - allocate(sizeof(T), handler)); + asio_handler_allocate( + sizeof(T), std::addressof(handler))); try { t = new(t) T{handler, @@ -33,8 +35,9 @@ P(DeducedHandler&& h, Args&&... args) } catch(...) { - beast_asio_helpers:: - deallocate(t, sizeof(T), handler); + using boost::asio::asio_handler_deallocate; + asio_handler_deallocate( + t, sizeof(T), std::addressof(handler)); throw; } } @@ -50,8 +53,9 @@ handler_ptr:: if(p_->t) { p_->t->~T(); - beast_asio_helpers:: - deallocate(p_->t, sizeof(T), p_->handler); + using boost::asio::asio_handler_deallocate; + asio_handler_deallocate( + p_->t, sizeof(T), std::addressof(p_->handler)); } delete p_; } @@ -103,8 +107,9 @@ release_handler() -> BOOST_ASSERT(p_); BOOST_ASSERT(p_->t); p_->t->~T(); - beast_asio_helpers:: - deallocate(p_->t, sizeof(T), p_->handler); + using boost::asio::asio_handler_deallocate; + asio_handler_deallocate( + p_->t, sizeof(T), std::addressof(p_->handler)); p_->t = nullptr; return std::move(p_->handler); } @@ -118,8 +123,9 @@ invoke(Args&&... args) BOOST_ASSERT(p_); BOOST_ASSERT(p_->t); p_->t->~T(); - beast_asio_helpers:: - deallocate(p_->t, sizeof(T), p_->handler); + using boost::asio::asio_handler_deallocate; + asio_handler_deallocate( + p_->t, sizeof(T), std::addressof(p_->handler)); p_->t = nullptr; p_->handler(std::forward(args)...); } diff --git a/include/beast/http/impl/async_read.ipp b/include/beast/http/impl/async_read.ipp index 08f269e3..159936d2 100644 --- a/include/beast/http/impl/async_read.ipp +++ b/include/beast/http/impl/async_read.ipp @@ -13,9 +13,11 @@ #include #include #include -#include #include #include +#include +#include +#include #include #include @@ -43,12 +45,12 @@ class read_some_buffer_op data(Handler& handler, Stream& s_, DynamicBuffer& db_, basic_parser& p_) - : cont(beast_asio_helpers:: - is_continuation(handler)) - , s(s_) + : s(s_) , db(db_) , p(p_) { + using boost::asio::asio_handler_is_continuation; + cont = asio_handler_is_continuation(std::addressof(handler)); } }; @@ -76,8 +78,9 @@ public: asio_handler_allocate(std::size_t size, read_some_buffer_op* op) { - return beast_asio_helpers:: - allocate(size, op->d_.handler()); + using boost::asio::asio_handler_allocate; + return asio_handler_allocate( + size, std::addressof(op->d_.handler())); } friend @@ -86,8 +89,9 @@ public: void* p, std::size_t size, read_some_buffer_op* op) { - return beast_asio_helpers:: - deallocate(p, size, op->d_.handler()); + using boost::asio::asio_handler_deallocate; + asio_handler_deallocate( + p, size, std::addressof(op->d_.handler())); } friend @@ -104,8 +108,9 @@ public: asio_handler_invoke(Function&& f, read_some_buffer_op* op) { - return beast_asio_helpers:: - invoke(f, op->d_.handler()); + using boost::asio::asio_handler_invoke; + asio_handler_invoke( + f, std::addressof(op->d_.handler())); } }; @@ -233,12 +238,12 @@ class read_some_body_op data(Handler& handler, Stream& s_, DynamicBuffer& db_, basic_parser& p_) - : cont(beast_asio_helpers:: - is_continuation(handler)) - , s(s_) + : s(s_) , db(db_) , p(p_) { + using boost::asio::asio_handler_is_continuation; + cont = asio_handler_is_continuation(std::addressof(handler)); } }; @@ -266,8 +271,9 @@ public: asio_handler_allocate(std::size_t size, read_some_body_op* op) { - return beast_asio_helpers:: - allocate(size, op->d_.handler()); + using boost::asio::asio_handler_allocate; + return asio_handler_allocate( + size, std::addressof(op->d_.handler())); } friend @@ -276,8 +282,9 @@ public: void* p, std::size_t size, read_some_body_op* op) { - return beast_asio_helpers:: - deallocate(p, size, op->d_.handler()); + using boost::asio::asio_handler_deallocate; + asio_handler_deallocate( + p, size, std::addressof(op->d_.handler())); } friend @@ -294,8 +301,9 @@ public: asio_handler_invoke(Function&& f, read_some_body_op* op) { - return beast_asio_helpers:: - invoke(f, op->d_.handler()); + using boost::asio::asio_handler_invoke; + asio_handler_invoke( + f, std::addressof(op->d_.handler())); } }; @@ -374,12 +382,12 @@ class parse_op data(Handler& handler, Stream& s_, DynamicBuffer& db_, basic_parser& p_) - : cont(beast_asio_helpers:: - is_continuation(handler)) - , s(s_) + : s(s_) , db(db_) , p(p_) { + using boost::asio::asio_handler_is_continuation; + cont = asio_handler_is_continuation(std::addressof(handler)); } }; @@ -407,8 +415,9 @@ public: asio_handler_allocate( std::size_t size, parse_op* op) { - return beast_asio_helpers:: - allocate(size, op->d_.handler()); + using boost::asio::asio_handler_allocate; + return asio_handler_allocate( + size, std::addressof(op->d_.handler())); } friend @@ -417,8 +426,9 @@ public: void* p, std::size_t size, parse_op* op) { - return beast_asio_helpers:: - deallocate(p, size, op->d_.handler()); + using boost::asio::asio_handler_deallocate; + asio_handler_deallocate( + p, size, std::addressof(op->d_.handler())); } friend @@ -435,8 +445,9 @@ public: asio_handler_invoke( Function&& f, parse_op* op) { - return beast_asio_helpers:: - invoke(f, op->d_.handler()); + using boost::asio::asio_handler_invoke; + asio_handler_invoke( + f, std::addressof(op->d_.handler())); } }; @@ -486,12 +497,12 @@ class read_message_op data(Handler& handler, Stream& s_, DynamicBuffer& sb_, message_type& m_) - : cont(beast_asio_helpers:: - is_continuation(handler)) - , s(s_) + : s(s_) , db(sb_) , m(m_) { + using boost::asio::asio_handler_is_continuation; + cont = asio_handler_is_continuation(std::addressof(handler)); } }; @@ -516,16 +527,18 @@ public: void* asio_handler_allocate( std::size_t size, read_message_op* op) { - return beast_asio_helpers:: - allocate(size, op->d_.handler()); + using boost::asio::asio_handler_allocate; + return asio_handler_allocate( + size, std::addressof(op->d_.handler())); } friend void asio_handler_deallocate( void* p, std::size_t size, read_message_op* op) { - return beast_asio_helpers:: - deallocate(p, size, op->d_.handler()); + using boost::asio::asio_handler_deallocate; + asio_handler_deallocate( + p, size, std::addressof(op->d_.handler())); } friend @@ -538,8 +551,9 @@ public: friend void asio_handler_invoke(Function&& f, read_message_op* op) { - return beast_asio_helpers:: - invoke(f, op->d_.handler()); + using boost::asio::asio_handler_invoke; + asio_handler_invoke( + f, std::addressof(op->d_.handler())); } }; diff --git a/include/beast/http/impl/read.ipp b/include/beast/http/impl/read.ipp index 98c8c938..651a7005 100644 --- a/include/beast/http/impl/read.ipp +++ b/include/beast/http/impl/read.ipp @@ -13,9 +13,11 @@ #include #include #include -#include #include #include +#include +#include +#include #include #include diff --git a/include/beast/http/impl/write.ipp b/include/beast/http/impl/write.ipp index ea14dbbf..129e4f9b 100644 --- a/include/beast/http/impl/write.ipp +++ b/include/beast/http/impl/write.ipp @@ -13,11 +13,13 @@ #include #include #include -#include #include #include #include #include +#include +#include +#include #include #include #include @@ -93,11 +95,11 @@ class write_streambuf_op data(Handler& handler, Stream& s_, multi_buffer&& sb_) - : cont(beast_asio_helpers:: - is_continuation(handler)) - , s(s_) + : s(s_) , b(std::move(sb_)) { + using boost::asio::asio_handler_is_continuation; + cont = asio_handler_is_continuation(std::addressof(handler)); } }; @@ -124,16 +126,18 @@ public: void* asio_handler_allocate( std::size_t size, write_streambuf_op* op) { - return beast_asio_helpers:: - allocate(size, op->d_.handler()); + using boost::asio::asio_handler_allocate; + return asio_handler_allocate( + size, std::addressof(op->d_.handler())); } friend void asio_handler_deallocate( void* p, std::size_t size, write_streambuf_op* op) { - return beast_asio_helpers:: - deallocate(p, size, op->d_.handler()); + using boost::asio::asio_handler_deallocate; + asio_handler_deallocate( + p, size, std::addressof(op->d_.handler())); } friend @@ -146,8 +150,9 @@ public: friend void asio_handler_invoke(Function&& f, write_streambuf_op* op) { - return beast_asio_helpers:: - invoke(f, op->d_.handler()); + using boost::asio::asio_handler_invoke; + asio_handler_invoke( + f, std::addressof(op->d_.handler())); } }; @@ -291,11 +296,11 @@ class write_op data(Handler& handler, Stream& s_, message const& m_) - : cont(beast_asio_helpers:: - is_continuation(handler)) - , s(s_) + : s(s_) , wp(m_) { + using boost::asio::asio_handler_is_continuation; + cont = asio_handler_is_continuation(std::addressof(handler)); } }; @@ -375,16 +380,18 @@ public: void* asio_handler_allocate( std::size_t size, write_op* op) { - return beast_asio_helpers:: - allocate(size, op->d_.handler()); + using boost::asio::asio_handler_allocate; + return asio_handler_allocate( + size, std::addressof(op->d_.handler())); } friend void asio_handler_deallocate( void* p, std::size_t size, write_op* op) { - return beast_asio_helpers:: - deallocate(p, size, op->d_.handler()); + using boost::asio::asio_handler_deallocate; + asio_handler_deallocate( + p, size, std::addressof(op->d_.handler())); } friend @@ -397,8 +404,9 @@ public: friend void asio_handler_invoke(Function&& f, write_op* op) { - return beast_asio_helpers:: - invoke(f, op->d_.handler()); + using boost::asio::asio_handler_invoke; + asio_handler_invoke( + f, std::addressof(op->d_.handler())); } }; diff --git a/include/beast/websocket/impl/accept.ipp b/include/beast/websocket/impl/accept.ipp index f59703b6..c996121d 100644 --- a/include/beast/websocket/impl/accept.ipp +++ b/include/beast/websocket/impl/accept.ipp @@ -15,9 +15,11 @@ #include #include #include -#include #include #include +#include +#include +#include #include #include #include @@ -92,16 +94,18 @@ public: void* asio_handler_allocate( std::size_t size, response_op* op) { - return beast_asio_helpers:: - allocate(size, op->d_.handler()); + using boost::asio::asio_handler_allocate; + return asio_handler_allocate( + size, std::addressof(op->d_.handler())); } friend void asio_handler_deallocate( void* p, std::size_t size, response_op* op) { - return beast_asio_helpers:: - deallocate(p, size, op->d_.handler()); + using boost::asio::asio_handler_deallocate; + asio_handler_deallocate( + p, size, std::addressof(op->d_.handler())); } friend @@ -114,8 +118,9 @@ public: friend void asio_handler_invoke(Function&& f, response_op* op) { - return beast_asio_helpers:: - invoke(f, op->d_.handler()); + using boost::asio::asio_handler_invoke; + asio_handler_invoke( + f, std::addressof(op->d_.handler())); } }; @@ -173,20 +178,22 @@ class stream::accept_op data(Handler& handler, stream& ws_, Decorator const& decorator_) - : cont(beast_asio_helpers::is_continuation(handler)) - , ws(ws_) + : ws(ws_) , decorator(decorator_) { + using boost::asio::asio_handler_is_continuation; + cont = asio_handler_is_continuation(std::addressof(handler)); } template data(Handler& handler, stream& ws_, Buffers const& buffers, Decorator const& decorator_) - : cont(beast_asio_helpers::is_continuation(handler)) - , ws(ws_) + : ws(ws_) , decorator(decorator_) { + using boost::asio::asio_handler_is_continuation; + cont = asio_handler_is_continuation(std::addressof(handler)); using boost::asio::buffer_copy; using boost::asio::buffer_size; // VFALCO What about catch(std::length_error const&)? @@ -218,16 +225,18 @@ public: void* asio_handler_allocate( std::size_t size, accept_op* op) { - return beast_asio_helpers:: - allocate(size, op->d_.handler()); + using boost::asio::asio_handler_allocate; + return asio_handler_allocate( + size, std::addressof(op->d_.handler())); } friend void asio_handler_deallocate( void* p, std::size_t size, accept_op* op) { - return beast_asio_helpers:: - deallocate(p, size, op->d_.handler()); + using boost::asio::asio_handler_deallocate; + asio_handler_deallocate( + p, size, std::addressof(op->d_.handler())); } friend @@ -240,8 +249,9 @@ public: friend void asio_handler_invoke(Function&& f, accept_op* op) { - return beast_asio_helpers:: - invoke(f, op->d_.handler()); + using boost::asio::asio_handler_invoke; + asio_handler_invoke( + f, std::addressof(op->d_.handler())); } }; @@ -690,11 +700,12 @@ async_accept(http::header const& req, async_completion init{handler}; reset(); + using boost::asio::asio_handler_is_continuation; response_op>{init.completion_handler, *this, req, &default_decorate_res, - beast_asio_helpers::is_continuation( - init.completion_handler)}; + asio_handler_is_continuation( + std::addressof(init.completion_handler))}; return init.result.get(); } @@ -715,11 +726,12 @@ async_accept_ex(http::header const& req, async_completion init{handler}; reset(); + using boost::asio::asio_handler_is_continuation; response_op>{ init.completion_handler, *this, req, decorator, - beast_asio_helpers::is_continuation( - init.completion_handler)}; + asio_handler_is_continuation( + std::addressof(init.completion_handler))}; return init.result.get(); } @@ -741,11 +753,12 @@ async_accept(http::header const& req, async_completion init{handler}; reset(); + using boost::asio::asio_handler_is_continuation; response_op>{ init.completion_handler, *this, req, buffers, - &default_decorate_res, beast_asio_helpers:: - is_continuation(init.completion_handler)}; + &default_decorate_res, asio_handler_is_continuation( + std::addressof(init.completion_handler))}; return init.result.get(); } @@ -771,11 +784,11 @@ async_accept_ex(http::header const& req, async_completion init{handler}; reset(); + using boost::asio::asio_handler_is_continuation; response_op>{init.completion_handler, - *this, req, buffers, decorator, - beast_asio_helpers::is_continuation( - init.completion_handler)}; + *this, req, buffers, decorator, asio_handler_is_continuation( + std::addressof(init.completion_handler))}; return init.result.get(); } diff --git a/include/beast/websocket/impl/close.ipp b/include/beast/websocket/impl/close.ipp index 1974dcf6..42c9fdeb 100644 --- a/include/beast/websocket/impl/close.ipp +++ b/include/beast/websocket/impl/close.ipp @@ -8,10 +8,12 @@ #ifndef BEAST_WEBSOCKET_IMPL_CLOSE_IPP #define BEAST_WEBSOCKET_IMPL_CLOSE_IPP -#include #include #include #include +#include +#include +#include #include namespace beast { @@ -37,11 +39,11 @@ class stream::close_op data(Handler& handler, stream& ws_, close_reason const& cr_) - : cont(beast_asio_helpers:: - is_continuation(handler)) - , ws(ws_) + : ws(ws_) , cr(cr_) { + using boost::asio::asio_handler_is_continuation; + cont = asio_handler_is_continuation(std::addressof(handler)); ws.template write_close< static_buffer>(fb, cr); } @@ -77,16 +79,18 @@ public: void* asio_handler_allocate( std::size_t size, close_op* op) { - return beast_asio_helpers:: - allocate(size, op->d_.handler()); + using boost::asio::asio_handler_allocate; + return asio_handler_allocate( + size, std::addressof(op->d_.handler())); } friend void asio_handler_deallocate( void* p, std::size_t size, close_op* op) { - return beast_asio_helpers:: - deallocate(p, size, op->d_.handler()); + using boost::asio::asio_handler_deallocate; + asio_handler_deallocate( + p, size, std::addressof(op->d_.handler())); } friend @@ -99,8 +103,9 @@ public: friend void asio_handler_invoke(Function&& f, close_op* op) { - return beast_asio_helpers:: - invoke(f, op->d_.handler()); + using boost::asio::asio_handler_invoke; + asio_handler_invoke( + f, std::addressof(op->d_.handler())); } }; diff --git a/include/beast/websocket/impl/handshake.ipp b/include/beast/websocket/impl/handshake.ipp index 2653dcbe..944c7685 100644 --- a/include/beast/websocket/impl/handshake.ipp +++ b/include/beast/websocket/impl/handshake.ipp @@ -12,9 +12,11 @@ #include #include #include -#include #include #include +#include +#include +#include #include #include @@ -45,13 +47,13 @@ class stream::handshake_op string_view const& host, string_view const& target, Decorator const& decorator) - : cont(beast_asio_helpers:: - is_continuation(handler)) - , ws(ws_) + : ws(ws_) , res_p(res_p_) , req(ws.build_request(key, host, target, decorator)) { + using boost::asio::asio_handler_is_continuation; + cont = asio_handler_is_continuation(std::addressof(handler)); ws.reset(); } }; @@ -78,16 +80,18 @@ public: void* asio_handler_allocate( std::size_t size, handshake_op* op) { - return beast_asio_helpers:: - allocate(size, op->d_.handler()); + using boost::asio::asio_handler_allocate; + return asio_handler_allocate( + size, std::addressof(op->d_.handler())); } friend void asio_handler_deallocate( void* p, std::size_t size, handshake_op* op) { - return beast_asio_helpers:: - deallocate(p, size, op->d_.handler()); + using boost::asio::asio_handler_deallocate; + asio_handler_deallocate( + p, size, std::addressof(op->d_.handler())); } friend @@ -100,8 +104,9 @@ public: friend void asio_handler_invoke(Function&& f, handshake_op* op) { - return beast_asio_helpers:: - invoke(f, op->d_.handler()); + using boost::asio::asio_handler_invoke; + asio_handler_invoke( + f, std::addressof(op->d_.handler())); } }; diff --git a/include/beast/websocket/impl/ping.ipp b/include/beast/websocket/impl/ping.ipp index e39b51c0..e59b6cf7 100644 --- a/include/beast/websocket/impl/ping.ipp +++ b/include/beast/websocket/impl/ping.ipp @@ -9,10 +9,12 @@ #define BEAST_WEBSOCKET_IMPL_PING_IPP #include -#include #include #include #include +#include +#include +#include #include namespace beast { @@ -35,10 +37,10 @@ class stream::ping_op data(Handler& handler, stream& ws_, opcode op_, ping_data const& payload) - : cont(beast_asio_helpers:: - is_continuation(handler)) - , ws(ws_) + : ws(ws_) { + using boost::asio::asio_handler_is_continuation; + cont = asio_handler_is_continuation(std::addressof(handler)); using boost::asio::buffer; using boost::asio::buffer_copy; ws.template write_ping< @@ -74,16 +76,18 @@ public: void* asio_handler_allocate( std::size_t size, ping_op* op) { - return beast_asio_helpers:: - allocate(size, op->d_.handler()); + using boost::asio::asio_handler_allocate; + return asio_handler_allocate( + size, std::addressof(op->d_.handler())); } friend void asio_handler_deallocate( void* p, std::size_t size, ping_op* op) { - return beast_asio_helpers:: - deallocate(p, size, op->d_.handler()); + using boost::asio::asio_handler_deallocate; + asio_handler_deallocate( + p, size, std::addressof(op->d_.handler())); } friend @@ -96,8 +100,9 @@ public: friend void asio_handler_invoke(Function&& f, ping_op* op) { - return beast_asio_helpers:: - invoke(f, op->d_.handler()); + using boost::asio::asio_handler_invoke; + asio_handler_invoke( + f, std::addressof(op->d_.handler())); } }; diff --git a/include/beast/websocket/impl/read.ipp b/include/beast/websocket/impl/read.ipp index 5ea61448..c1f97c6d 100644 --- a/include/beast/websocket/impl/read.ipp +++ b/include/beast/websocket/impl/read.ipp @@ -10,11 +10,13 @@ #include #include -#include #include #include #include #include +#include +#include +#include #include #include #include @@ -57,12 +59,12 @@ class stream::read_frame_op data(Handler& handler, stream& ws_, frame_info& fi_, DynamicBuffer& sb_) - : cont(beast_asio_helpers:: - is_continuation(handler)) - , ws(ws_) + : ws(ws_) , fi(fi_) , db(sb_) { + using boost::asio::asio_handler_is_continuation; + cont = asio_handler_is_continuation(std::addressof(handler)); } }; @@ -101,16 +103,18 @@ public: void* asio_handler_allocate( std::size_t size, read_frame_op* op) { - return beast_asio_helpers:: - allocate(size, op->d_.handler()); + using boost::asio::asio_handler_allocate; + return asio_handler_allocate( + size, std::addressof(op->d_.handler())); } friend void asio_handler_deallocate( void* p, std::size_t size, read_frame_op* op) { - return beast_asio_helpers:: - deallocate(p, size, op->d_.handler()); + using boost::asio::asio_handler_deallocate; + asio_handler_deallocate( + p, size, std::addressof(op->d_.handler())); } friend @@ -123,8 +127,9 @@ public: friend void asio_handler_invoke(Function&& f, read_frame_op* op) { - return beast_asio_helpers:: - invoke(f, op->d_.handler()); + using boost::asio::asio_handler_invoke; + asio_handler_invoke( + f, std::addressof(op->d_.handler())); } }; @@ -1005,12 +1010,12 @@ class stream::read_op data(Handler& handler, stream& ws_, opcode& op_, DynamicBuffer& sb_) - : cont(beast_asio_helpers:: - is_continuation(handler)) - , ws(ws_) + : ws(ws_) , op(op_) , db(sb_) { + using boost::asio::asio_handler_is_continuation; + cont = asio_handler_is_continuation(std::addressof(handler)); } }; @@ -1036,16 +1041,18 @@ public: void* asio_handler_allocate( std::size_t size, read_op* op) { - return beast_asio_helpers:: - allocate(size, op->d_.handler()); + using boost::asio::asio_handler_allocate; + return asio_handler_allocate( + size, std::addressof(op->d_.handler())); } friend void asio_handler_deallocate( void* p, std::size_t size, read_op* op) { - return beast_asio_helpers:: - deallocate(p, size, op->d_.handler()); + using boost::asio::asio_handler_deallocate; + asio_handler_deallocate( + p, size, std::addressof(op->d_.handler())); } friend @@ -1058,8 +1065,9 @@ public: friend void asio_handler_invoke(Function&& f, read_op* op) { - return beast_asio_helpers:: - invoke(f, op->d_.handler()); + using boost::asio::asio_handler_invoke; + asio_handler_invoke( + f, std::addressof(op->d_.handler())); } }; diff --git a/include/beast/websocket/impl/ssl.ipp b/include/beast/websocket/impl/ssl.ipp index 37245db2..791894df 100644 --- a/include/beast/websocket/impl/ssl.ipp +++ b/include/beast/websocket/impl/ssl.ipp @@ -9,9 +9,11 @@ #define BEAST_WEBSOCKET_IMPL_SSL_IPP_INCLUDED #include -#include #include #include +#include +#include +#include namespace beast { namespace websocket { @@ -45,10 +47,10 @@ class teardown_ssl_op int state = 0; data(Handler& handler, stream_type& stream_) - : cont(beast_asio_helpers:: - is_continuation(handler)) - , stream(stream_) + : stream(stream_) { + using boost::asio::asio_handler_is_continuation; + cont = asio_handler_is_continuation(std::addressof(handler)); } }; @@ -71,16 +73,18 @@ public: void* asio_handler_allocate(std::size_t size, teardown_ssl_op* op) { - return beast_asio_helpers:: - allocate(size, op->d_.handler()); + using boost::asio::asio_handler_allocate; + return asio_handler_allocate( + size, std::addressof(op->d_.handler())); } friend void asio_handler_deallocate(void* p, std::size_t size, teardown_ssl_op* op) { - return beast_asio_helpers:: - deallocate(p, size, op->d_.handler()); + using boost::asio::asio_handler_deallocate; + asio_handler_deallocate( + p, size, std::addressof(op->d_.handler())); } friend @@ -95,8 +99,9 @@ public: void asio_handler_invoke(Function&& f, teardown_ssl_op* op) { - return beast_asio_helpers:: - invoke(f, op->d_.handler()); + using boost::asio::asio_handler_invoke; + asio_handler_invoke( + f, std::addressof(op->d_.handler())); } }; diff --git a/include/beast/websocket/impl/teardown.ipp b/include/beast/websocket/impl/teardown.ipp index 98ed8beb..f29a517b 100644 --- a/include/beast/websocket/impl/teardown.ipp +++ b/include/beast/websocket/impl/teardown.ipp @@ -9,9 +9,11 @@ #define BEAST_WEBSOCKET_IMPL_TEARDOWN_IPP #include -#include #include #include +#include +#include +#include #include namespace beast { @@ -33,10 +35,10 @@ class teardown_tcp_op int state = 0; data(Handler& handler, socket_type& socket_) - : cont(beast_asio_helpers:: - is_continuation(handler)) - , socket(socket_) + : socket(socket_) { + using boost::asio::asio_handler_is_continuation; + cont = asio_handler_is_continuation(std::addressof(handler)); } }; @@ -59,16 +61,18 @@ public: void* asio_handler_allocate(std::size_t size, teardown_tcp_op* op) { - return beast_asio_helpers:: - allocate(size, op->d_.handler()); + using boost::asio::asio_handler_allocate; + return asio_handler_allocate( + size, std::addressof(op->d_.handler())); } friend void asio_handler_deallocate(void* p, std::size_t size, teardown_tcp_op* op) { - return beast_asio_helpers:: - deallocate(p, size, op->d_.handler()); + using boost::asio::asio_handler_deallocate; + asio_handler_deallocate( + p, size, std::addressof(op->d_.handler())); } friend @@ -82,8 +86,9 @@ public: void asio_handler_invoke(Function&& f, teardown_tcp_op* op) { - return beast_asio_helpers:: - invoke(f, op->d_.handler()); + using boost::asio::asio_handler_invoke; + asio_handler_invoke( + f, std::addressof(op->d_.handler())); } }; diff --git a/include/beast/websocket/impl/write.ipp b/include/beast/websocket/impl/write.ipp index 7ead6bb2..df6e564e 100644 --- a/include/beast/websocket/impl/write.ipp +++ b/include/beast/websocket/impl/write.ipp @@ -12,12 +12,14 @@ #include #include #include -#include #include #include #include #include #include +#include +#include +#include #include #include #include @@ -31,7 +33,6 @@ class stream::write_frame_op { struct data : op { - Handler& handler; bool cont; stream& ws; consuming_buffers cb; @@ -43,15 +44,14 @@ class stream::write_frame_op int state = 0; int entry_state; - data(Handler& handler_, stream& ws_, + data(Handler& handler, stream& ws_, bool fin_, Buffers const& bs) - : handler(handler_) - , cont(beast_asio_helpers:: - is_continuation(handler)) - , ws(ws_) + : ws(ws_) , cb(bs) , fin(fin_) { + using boost::asio::asio_handler_is_continuation; + cont = asio_handler_is_continuation(std::addressof(handler)); } }; @@ -90,16 +90,18 @@ public: void* asio_handler_allocate( std::size_t size, write_frame_op* op) { - return beast_asio_helpers:: - allocate(size, op->d_.handler()); + using boost::asio::asio_handler_allocate; + return asio_handler_allocate( + size, std::addressof(op->d_.handler())); } friend void asio_handler_deallocate( void* p, std::size_t size, write_frame_op* op) { - return beast_asio_helpers:: - deallocate(p, size, op->d_.handler()); + using boost::asio::asio_handler_deallocate; + asio_handler_deallocate( + p, size, std::addressof(op->d_.handler())); } friend @@ -112,8 +114,9 @@ public: friend void asio_handler_invoke(Function&& f, write_frame_op* op) { - return beast_asio_helpers:: - invoke(f, op->d_.handler()); + using boost::asio::asio_handler_invoke; + asio_handler_invoke( + f, std::addressof(op->d_.handler())); } }; @@ -801,12 +804,12 @@ class stream::write_op data(Handler& handler, stream& ws_, Buffers const& bs) - : cont(beast_asio_helpers:: - is_continuation(handler)) - , ws(ws_) + : ws(ws_) , cb(bs) , remain(boost::asio::buffer_size(cb)) { + using boost::asio::asio_handler_is_continuation; + cont = asio_handler_is_continuation(std::addressof(handler)); } }; @@ -832,16 +835,18 @@ public: void* asio_handler_allocate( std::size_t size, write_op* op) { - return beast_asio_helpers:: - allocate(size, op->d_.handler()); + using boost::asio::asio_handler_allocate; + return asio_handler_allocate( + size, std::addressof(op->d_.handler())); } friend void asio_handler_deallocate( void* p, std::size_t size, write_op* op) { - return beast_asio_helpers:: - deallocate(p, size, op->d_.handler()); + using boost::asio::asio_handler_deallocate; + asio_handler_deallocate( + p, size, std::addressof(op->d_.handler())); } friend @@ -854,8 +859,9 @@ public: friend void asio_handler_invoke(Function&& f, write_op* op) { - return beast_asio_helpers:: - invoke(f, op->d_.handler()); + using boost::asio::asio_handler_invoke; + asio_handler_invoke( + f, std::addressof(op->d_.handler())); } };