From 4ab2b5e5e74fff103fb6279686e4a90199373c71 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Thu, 5 Jan 2017 09:07:18 -0500 Subject: [PATCH] Add handler helpers --- CHANGELOG.md | 1 + examples/http_async_server.hpp | 12 +- include/beast/core.hpp | 2 + include/beast/core/detail/bind_handler.hpp | 12 +- include/beast/core/handler_alloc.hpp | 6 +- include/beast/core/handler_helpers.hpp | 104 ++++++++++++++++++ .../beast/core/impl/dynabuf_readstream.ipp | 13 +-- include/beast/core/impl/handler_ptr.ipp | 11 +- include/beast/http/impl/parse.ipp | 10 +- include/beast/http/impl/read.ipp | 18 +-- include/beast/http/impl/write.ipp | 18 +-- include/beast/websocket/impl/accept.ipp | 18 +-- include/beast/websocket/impl/close.ipp | 12 +- include/beast/websocket/impl/handshake.ipp | 13 +-- include/beast/websocket/impl/ping.ipp | 10 +- include/beast/websocket/impl/read.ipp | 18 +-- include/beast/websocket/impl/ssl.ipp | 10 +- include/beast/websocket/impl/teardown.ipp | 13 +-- include/beast/websocket/impl/write.ipp | 22 ++-- 19 files changed, 208 insertions(+), 115 deletions(-) create mode 100644 include/beast/core/handler_helpers.hpp diff --git a/CHANGELOG.md b/CHANGELOG.md index 113af4cb..e7238741 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ * Fix broken Intellisense * Implement the Asio deallocation-before-invocation guarantee +* Add handler helpers -------------------------------------------------------------------------------- diff --git a/examples/http_async_server.hpp b/examples/http_async_server.hpp index bfb5b9ba..2c1df4b4 100644 --- a/examples/http_async_server.hpp +++ b/examples/http_async_server.hpp @@ -12,6 +12,7 @@ #include "mime_type.hpp" #include +#include #include #include #include @@ -89,9 +90,6 @@ private: bool isRequest, class Body, class Fields> class write_op { - using alloc_type = - handler_alloc; - struct data { bool cont; @@ -100,7 +98,7 @@ private: data(Handler& handler, Stream& s_, message&& m_) - : cont(boost_asio_handler_cont_helpers:: + : cont(beast_asio_helpers:: is_continuation(handler)) , s(s_) , m(std::move(m_)) @@ -140,7 +138,7 @@ private: void* asio_handler_allocate( std::size_t size, write_op* op) { - return boost_asio_handler_alloc_helpers:: + return beast_asio_helpers:: allocate(size, op->d_.handler()); } @@ -148,7 +146,7 @@ private: void asio_handler_deallocate( void* p, std::size_t size, write_op* op) { - return boost_asio_handler_alloc_helpers:: + return beast_asio_helpers:: deallocate(p, size, op->d_.handler()); } @@ -162,7 +160,7 @@ private: friend void asio_handler_invoke(Function&& f, write_op* op) { - return boost_asio_handler_invoke_helpers:: + return beast_asio_helpers:: invoke(f, op->d_.handler()); } }; diff --git a/include/beast/core.hpp b/include/beast/core.hpp index dc750eea..a46ad003 100644 --- a/include/beast/core.hpp +++ b/include/beast/core.hpp @@ -18,6 +18,8 @@ #include #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 6b540c28..f53b1efa 100644 --- a/include/beast/core/detail/bind_handler.hpp +++ b/include/beast/core/detail/bind_handler.hpp @@ -8,10 +8,8 @@ #ifndef BEAST_BIND_DETAIL_HANDLER_HPP #define BEAST_BIND_DETAIL_HANDLER_HPP +#include #include -#include -#include -#include #include namespace beast { @@ -69,7 +67,7 @@ public: asio_handler_allocate( std::size_t size, bound_handler* h) { - return boost_asio_handler_alloc_helpers:: + return beast_asio_helpers:: allocate(size, h->h_); } @@ -78,7 +76,7 @@ public: asio_handler_deallocate( void* p, std::size_t size, bound_handler* h) { - boost_asio_handler_alloc_helpers:: + beast_asio_helpers:: deallocate(p, size, h->h_); } @@ -86,7 +84,7 @@ public: bool asio_handler_is_continuation(bound_handler* h) { - return boost_asio_handler_cont_helpers:: + return beast_asio_helpers:: is_continuation (h->h_); } @@ -95,7 +93,7 @@ public: void asio_handler_invoke(F&& f, bound_handler* h) { - boost_asio_handler_invoke_helpers:: + beast_asio_helpers:: invoke(f, h->h_); } }; diff --git a/include/beast/core/handler_alloc.hpp b/include/beast/core/handler_alloc.hpp index b10ed8e2..f6692c0b 100644 --- a/include/beast/core/handler_alloc.hpp +++ b/include/beast/core/handler_alloc.hpp @@ -8,7 +8,7 @@ #ifndef BEAST_HANDLER_ALLOC_HPP #define BEAST_HANDLER_ALLOC_HPP -#include +#include #include #include #include @@ -107,7 +107,7 @@ public: { auto const size = n * sizeof(T); return static_cast( - boost_asio_handler_alloc_helpers::allocate( + beast_asio_helpers::allocate( size, h_)); } @@ -115,7 +115,7 @@ public: deallocate(value_type* p, std::ptrdiff_t n) { auto const size = n * sizeof(T); - boost_asio_handler_alloc_helpers::deallocate( + beast_asio_helpers::deallocate( p, size, h_); } diff --git a/include/beast/core/handler_helpers.hpp b/include/beast/core/handler_helpers.hpp new file mode 100644 index 00000000..ee3f7979 --- /dev/null +++ b/include/beast/core/handler_helpers.hpp @@ -0,0 +1,104 @@ +// +// Copyright (c) 2013-2016 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 + +/* 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/dynabuf_readstream.ipp b/include/beast/core/impl/dynabuf_readstream.ipp index 43790f07..bcd7a0a5 100644 --- a/include/beast/core/impl/dynabuf_readstream.ipp +++ b/include/beast/core/impl/dynabuf_readstream.ipp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include namespace beast { @@ -21,9 +21,6 @@ template class dynabuf_readstream< Stream, DynamicBuffer>::read_some_op { - using alloc_type = - handler_alloc; - // VFALCO What about bool cont for is_continuation? struct data { @@ -63,7 +60,7 @@ public: void* asio_handler_allocate( std::size_t size, read_some_op* op) { - return boost_asio_handler_alloc_helpers:: + return beast_asio_helpers:: allocate(size, op->d_.handler()); } @@ -71,14 +68,14 @@ public: void asio_handler_deallocate( void* p, std::size_t size, read_some_op* op) { - return boost_asio_handler_alloc_helpers:: + return beast_asio_helpers:: deallocate(p, size, op->d_.handler()); } friend bool asio_handler_is_continuation(read_some_op* op) { - return boost_asio_handler_cont_helpers:: + return beast_asio_helpers:: is_continuation(op->d_.handler()); } @@ -86,7 +83,7 @@ public: friend void asio_handler_invoke(Function&& f, read_some_op* op) { - return boost_asio_handler_invoke_helpers:: + return beast_asio_helpers:: invoke(f, op->d_.handler()); } }; diff --git a/include/beast/core/impl/handler_ptr.ipp b/include/beast/core/impl/handler_ptr.ipp index 152628c4..0f57a24d 100644 --- a/include/beast/core/impl/handler_ptr.ipp +++ b/include/beast/core/impl/handler_ptr.ipp @@ -8,6 +8,7 @@ #ifndef BEAST_IMPL_HANDLER_PTR_HPP #define BEAST_IMPL_HANDLER_PTR_HPP +#include #include #include #include @@ -23,7 +24,7 @@ P(DeducedHandler&& h, Args&&... args) , handler(std::forward(h)) { t = reinterpret_cast( - boost_asio_handler_alloc_helpers:: + beast_asio_helpers:: allocate(sizeof(T), handler)); try { @@ -32,7 +33,7 @@ P(DeducedHandler&& h, Args&&... args) } catch(...) { - boost_asio_handler_alloc_helpers:: + beast_asio_helpers:: deallocate(t, sizeof(T), handler); throw; } @@ -58,7 +59,7 @@ handler_ptr:: if(p_->t) { p_->t->~T(); - boost_asio_handler_alloc_helpers:: + beast_asio_helpers:: deallocate(p_->t, sizeof(T), p_->handler); } delete p_; @@ -90,7 +91,7 @@ release_handler() -> BOOST_ASSERT(p_); BOOST_ASSERT(p_->t); p_->t->~T(); - boost_asio_handler_alloc_helpers:: + beast_asio_helpers:: deallocate(p_->t, sizeof(T), p_->handler); p_->t = nullptr; return std::move(p_->handler); @@ -105,7 +106,7 @@ invoke(Args&&... args) BOOST_ASSERT(p_); BOOST_ASSERT(p_->t); p_->t->~T(); - boost_asio_handler_alloc_helpers:: + beast_asio_helpers:: deallocate(p_->t, sizeof(T), p_->handler); p_->t = nullptr; p_->handler(std::forward(args)...); diff --git a/include/beast/http/impl/parse.ipp b/include/beast/http/impl/parse.ipp index ab38c143..913b41b1 100644 --- a/include/beast/http/impl/parse.ipp +++ b/include/beast/http/impl/parse.ipp @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include #include @@ -35,7 +35,7 @@ class parse_op data(Handler& handler, Stream& s_, DynamicBuffer& sb_, Parser& p_) - : cont(boost_asio_handler_cont_helpers:: + : cont(beast_asio_helpers:: is_continuation(handler)) , s(s_) , db(sb_) @@ -68,7 +68,7 @@ public: void* asio_handler_allocate( std::size_t size, parse_op* op) { - return boost_asio_handler_alloc_helpers:: + return beast_asio_helpers:: allocate(size, op->d_.handler()); } @@ -76,7 +76,7 @@ public: void asio_handler_deallocate( void* p, std::size_t size, parse_op* op) { - return boost_asio_handler_alloc_helpers:: + return beast_asio_helpers:: deallocate(p, size, op->d_.handler()); } @@ -90,7 +90,7 @@ public: friend void asio_handler_invoke(Function&& f, parse_op* op) { - return boost_asio_handler_invoke_helpers:: + return beast_asio_helpers:: invoke(f, op->d_.handler()); } }; diff --git a/include/beast/http/impl/read.ipp b/include/beast/http/impl/read.ipp index d569c2e8..3f3961dd 100644 --- a/include/beast/http/impl/read.ipp +++ b/include/beast/http/impl/read.ipp @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include @@ -46,7 +46,7 @@ class read_header_op data(Handler& handler, Stream& s_, DynamicBuffer& sb_, message_type& m_) - : cont(boost_asio_handler_cont_helpers:: + : cont(beast_asio_helpers:: is_continuation(handler)) , s(s_) , db(sb_) @@ -78,7 +78,7 @@ public: void* asio_handler_allocate( std::size_t size, read_header_op* op) { - return boost_asio_handler_alloc_helpers:: + return beast_asio_helpers:: allocate(size, op->d_.handler()); } @@ -86,7 +86,7 @@ public: void asio_handler_deallocate( void* p, std::size_t size, read_header_op* op) { - return boost_asio_handler_alloc_helpers:: + return beast_asio_helpers:: deallocate(p, size, op->d_.handler()); } @@ -100,7 +100,7 @@ public: friend void asio_handler_invoke(Function&& f, read_header_op* op) { - return boost_asio_handler_invoke_helpers:: + return beast_asio_helpers:: invoke(f, op->d_.handler()); } }; @@ -219,7 +219,7 @@ class read_op data(Handler& handler, Stream& s_, DynamicBuffer& sb_, message_type& m_) - : cont(boost_asio_handler_cont_helpers:: + : cont(beast_asio_helpers:: is_continuation(handler)) , s(s_) , db(sb_) @@ -250,7 +250,7 @@ public: void* asio_handler_allocate( std::size_t size, read_op* op) { - return boost_asio_handler_alloc_helpers:: + return beast_asio_helpers:: allocate(size, op->d_.handler()); } @@ -258,7 +258,7 @@ public: void asio_handler_deallocate( void* p, std::size_t size, read_op* op) { - return boost_asio_handler_alloc_helpers:: + return beast_asio_helpers:: deallocate(p, size, op->d_.handler()); } @@ -272,7 +272,7 @@ public: friend void asio_handler_invoke(Function&& f, read_op* op) { - return boost_asio_handler_invoke_helpers:: + return beast_asio_helpers:: invoke(f, op->d_.handler()); } }; diff --git a/include/beast/http/impl/write.ipp b/include/beast/http/impl/write.ipp index 87e63e1f..c2f71043 100644 --- a/include/beast/http/impl/write.ipp +++ b/include/beast/http/impl/write.ipp @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include @@ -109,7 +109,7 @@ class write_streambuf_op data(Handler& handler, Stream& s_, streambuf&& sb_) - : cont(boost_asio_handler_cont_helpers:: + : cont(beast_asio_helpers:: is_continuation(handler)) , s(s_) , sb(std::move(sb_)) @@ -141,7 +141,7 @@ public: void* asio_handler_allocate( std::size_t size, write_streambuf_op* op) { - return boost_asio_handler_alloc_helpers:: + return beast_asio_helpers:: allocate(size, op->d_.handler()); } @@ -149,7 +149,7 @@ public: void asio_handler_deallocate( void* p, std::size_t size, write_streambuf_op* op) { - return boost_asio_handler_alloc_helpers:: + return beast_asio_helpers:: deallocate(p, size, op->d_.handler()); } @@ -163,7 +163,7 @@ public: friend void asio_handler_invoke(Function&& f, write_streambuf_op* op) { - return boost_asio_handler_invoke_helpers:: + return beast_asio_helpers:: invoke(f, op->d_.handler()); } }; @@ -303,7 +303,7 @@ class write_op data(Handler& handler, Stream& s_, message const& m_) - : cont(boost_asio_handler_cont_helpers:: + : cont(beast_asio_helpers:: is_continuation(handler)) , s(s_) , wp(m_) @@ -406,7 +406,7 @@ public: void* asio_handler_allocate( std::size_t size, write_op* op) { - return boost_asio_handler_alloc_helpers:: + return beast_asio_helpers:: allocate(size, op->d_.handler()); } @@ -414,7 +414,7 @@ public: void asio_handler_deallocate( void* p, std::size_t size, write_op* op) { - return boost_asio_handler_alloc_helpers:: + return beast_asio_helpers:: deallocate(p, size, op->d_.handler()); } @@ -428,7 +428,7 @@ public: friend void asio_handler_invoke(Function&& f, write_op* op) { - return boost_asio_handler_invoke_helpers:: + return beast_asio_helpers:: invoke(f, op->d_.handler()); } }; diff --git a/include/beast/websocket/impl/accept.ipp b/include/beast/websocket/impl/accept.ipp index 2d0e13d4..c33852c8 100644 --- a/include/beast/websocket/impl/accept.ipp +++ b/include/beast/websocket/impl/accept.ipp @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include @@ -78,7 +78,7 @@ public: void* asio_handler_allocate( std::size_t size, response_op* op) { - return boost_asio_handler_alloc_helpers:: + return beast_asio_helpers:: allocate(size, op->d_.handler()); } @@ -86,7 +86,7 @@ public: void asio_handler_deallocate( void* p, std::size_t size, response_op* op) { - return boost_asio_handler_alloc_helpers:: + return beast_asio_helpers:: deallocate(p, size, op->d_.handler()); } @@ -100,7 +100,7 @@ public: friend void asio_handler_invoke(Function&& f, response_op* op) { - return boost_asio_handler_invoke_helpers:: + return beast_asio_helpers:: invoke(f, op->d_.handler()); } }; @@ -154,7 +154,7 @@ class stream::accept_op template data(Handler& handler, stream& ws_, Buffers const& buffers) - : cont(boost_asio_handler_cont_helpers:: + : cont(beast_asio_helpers:: is_continuation(handler)) , ws(ws_) { @@ -195,7 +195,7 @@ public: void* asio_handler_allocate( std::size_t size, accept_op* op) { - return boost_asio_handler_alloc_helpers:: + return beast_asio_helpers:: allocate(size, op->d_.handler()); } @@ -203,7 +203,7 @@ public: void asio_handler_deallocate( void* p, std::size_t size, accept_op* op) { - return boost_asio_handler_alloc_helpers:: + return beast_asio_helpers:: deallocate(p, size, op->d_.handler()); } @@ -217,7 +217,7 @@ public: friend void asio_handler_invoke(Function&& f, accept_op* op) { - return boost_asio_handler_invoke_helpers:: + return beast_asio_helpers:: invoke(f, op->d_.handler()); } }; @@ -308,7 +308,7 @@ async_accept(http::request const& req, reset(); response_op{ completion.handler, *this, req, - boost_asio_handler_cont_helpers:: + beast_asio_helpers:: is_continuation(completion.handler)}; return completion.result.get(); } diff --git a/include/beast/websocket/impl/close.ipp b/include/beast/websocket/impl/close.ipp index e821e24f..7e929b58 100644 --- a/include/beast/websocket/impl/close.ipp +++ b/include/beast/websocket/impl/close.ipp @@ -8,7 +8,7 @@ #ifndef BEAST_WEBSOCKET_IMPL_CLOSE_IPP #define BEAST_WEBSOCKET_IMPL_CLOSE_IPP -#include +#include #include #include #include @@ -25,8 +25,6 @@ template template class stream::close_op { - using alloc_type = handler_alloc; - using fb_type = detail::frame_streambuf; struct data : op @@ -39,7 +37,7 @@ class stream::close_op data(Handler& handler, stream& ws_, close_reason const& cr_) - : cont(boost_asio_handler_cont_helpers:: + : cont(beast_asio_helpers:: is_continuation(handler)) , ws(ws_) , cr(cr_) @@ -80,7 +78,7 @@ public: void* asio_handler_allocate( std::size_t size, close_op* op) { - return boost_asio_handler_alloc_helpers:: + return beast_asio_helpers:: allocate(size, op->d_.handler()); } @@ -88,7 +86,7 @@ public: void asio_handler_deallocate( void* p, std::size_t size, close_op* op) { - return boost_asio_handler_alloc_helpers:: + return beast_asio_helpers:: deallocate(p, size, op->d_.handler()); } @@ -102,7 +100,7 @@ public: friend void asio_handler_invoke(Function&& f, close_op* op) { - return boost_asio_handler_invoke_helpers:: + return beast_asio_helpers:: invoke(f, op->d_.handler()); } }; diff --git a/include/beast/websocket/impl/handshake.ipp b/include/beast/websocket/impl/handshake.ipp index 3fc29e32..acc9cd2d 100644 --- a/include/beast/websocket/impl/handshake.ipp +++ b/include/beast/websocket/impl/handshake.ipp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include @@ -29,9 +29,6 @@ template template class stream::handshake_op { - using alloc_type = - handler_alloc; - struct data { bool cont; @@ -44,7 +41,7 @@ class stream::handshake_op data(Handler& handler, stream& ws_, boost::string_ref const& host, boost::string_ref const& resource) - : cont(boost_asio_handler_cont_helpers:: + : cont(beast_asio_helpers:: is_continuation(handler)) , ws(ws_) , req(ws.build_request(host, resource, key)) @@ -76,7 +73,7 @@ public: void* asio_handler_allocate( std::size_t size, handshake_op* op) { - return boost_asio_handler_alloc_helpers:: + return beast_asio_helpers:: allocate(size, op->d_.handler()); } @@ -84,7 +81,7 @@ public: void asio_handler_deallocate( void* p, std::size_t size, handshake_op* op) { - return boost_asio_handler_alloc_helpers:: + return beast_asio_helpers:: deallocate(p, size, op->d_.handler()); } @@ -98,7 +95,7 @@ public: friend void asio_handler_invoke(Function&& f, handshake_op* op) { - return boost_asio_handler_invoke_helpers:: + return beast_asio_helpers:: invoke(f, op->d_.handler()); } }; diff --git a/include/beast/websocket/impl/ping.ipp b/include/beast/websocket/impl/ping.ipp index f81f107b..d9e7ba51 100644 --- a/include/beast/websocket/impl/ping.ipp +++ b/include/beast/websocket/impl/ping.ipp @@ -9,7 +9,7 @@ #define BEAST_WEBSOCKET_IMPL_PING_IPP #include -#include +#include #include #include #include @@ -35,7 +35,7 @@ class stream::ping_op data(Handler& handler, stream& ws_, opcode op_, ping_data const& payload) - : cont(boost_asio_handler_cont_helpers:: + : cont(beast_asio_helpers:: is_continuation(handler)) , ws(ws_) { @@ -75,7 +75,7 @@ public: void* asio_handler_allocate( std::size_t size, ping_op* op) { - return boost_asio_handler_alloc_helpers:: + return beast_asio_helpers:: allocate(size, op->d_.handler()); } @@ -83,7 +83,7 @@ public: void asio_handler_deallocate( void* p, std::size_t size, ping_op* op) { - return boost_asio_handler_alloc_helpers:: + return beast_asio_helpers:: deallocate(p, size, op->d_.handler()); } @@ -97,7 +97,7 @@ public: friend void asio_handler_invoke(Function&& f, ping_op* op) { - return boost_asio_handler_invoke_helpers:: + return beast_asio_helpers:: invoke(f, op->d_.handler()); } }; diff --git a/include/beast/websocket/impl/read.ipp b/include/beast/websocket/impl/read.ipp index 2469b96f..d4469d7b 100644 --- a/include/beast/websocket/impl/read.ipp +++ b/include/beast/websocket/impl/read.ipp @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include #include @@ -54,7 +54,7 @@ class stream::read_frame_op data(Handler& handler, stream& ws_, frame_info& fi_, DynamicBuffer& sb_) - : cont(boost_asio_handler_cont_helpers:: + : cont(beast_asio_helpers:: is_continuation(handler)) , ws(ws_) , fi(fi_) @@ -99,7 +99,7 @@ public: void* asio_handler_allocate( std::size_t size, read_frame_op* op) { - return boost_asio_handler_alloc_helpers:: + return beast_asio_helpers:: allocate(size, op->d_.handler()); } @@ -107,7 +107,7 @@ public: void asio_handler_deallocate( void* p, std::size_t size, read_frame_op* op) { - return boost_asio_handler_alloc_helpers:: + return beast_asio_helpers:: deallocate(p, size, op->d_.handler()); } @@ -121,7 +121,7 @@ public: friend void asio_handler_invoke(Function&& f, read_frame_op* op) { - return boost_asio_handler_invoke_helpers:: + return beast_asio_helpers:: invoke(f, op->d_.handler()); } }; @@ -741,7 +741,7 @@ class stream::read_op data(Handler& handler, stream& ws_, opcode& op_, DynamicBuffer& sb_) - : cont(boost_asio_handler_cont_helpers:: + : cont(beast_asio_helpers:: is_continuation(handler)) , ws(ws_) , op(op_) @@ -773,7 +773,7 @@ public: void* asio_handler_allocate( std::size_t size, read_op* op) { - return boost_asio_handler_alloc_helpers:: + return beast_asio_helpers:: allocate(size, op->d_.handler()); } @@ -781,7 +781,7 @@ public: void asio_handler_deallocate( void* p, std::size_t size, read_op* op) { - return boost_asio_handler_alloc_helpers:: + return beast_asio_helpers:: deallocate(p, size, op->d_.handler()); } @@ -795,7 +795,7 @@ public: friend void asio_handler_invoke(Function&& f, read_op* op) { - return boost_asio_handler_invoke_helpers:: + return beast_asio_helpers:: invoke(f, op->d_.handler()); } }; diff --git a/include/beast/websocket/impl/ssl.ipp b/include/beast/websocket/impl/ssl.ipp index 09a95cec..5b3e5cf2 100644 --- a/include/beast/websocket/impl/ssl.ipp +++ b/include/beast/websocket/impl/ssl.ipp @@ -9,7 +9,7 @@ #define BEAST_WEBSOCKET_IMPL_SSL_IPP_INCLUDED #include -#include +#include #include #include @@ -45,7 +45,7 @@ class teardown_ssl_op int state = 0; data(Handler& handler, stream_type& stream_) - : cont(boost_asio_handler_cont_helpers:: + : cont(beast_asio_helpers:: is_continuation(handler)) , stream(stream_) { @@ -73,7 +73,7 @@ public: void* asio_handler_allocate(std::size_t size, teardown_ssl_op* op) { - return boost_asio_handler_alloc_helpers:: + return beast_asio_helpers:: allocate(size, op->d_.handler()); } @@ -81,7 +81,7 @@ public: void asio_handler_deallocate(void* p, std::size_t size, teardown_ssl_op* op) { - return boost_asio_handler_alloc_helpers:: + return beast_asio_helpers:: deallocate(p, size, op->d_.handler()); } @@ -97,7 +97,7 @@ public: void asio_handler_invoke(Function&& f, teardown_ssl_op* op) { - return boost_asio_handler_invoke_helpers:: + return beast_asio_helpers:: invoke(f, op->d_.handler()); } }; diff --git a/include/beast/websocket/impl/teardown.ipp b/include/beast/websocket/impl/teardown.ipp index e757d739..b2ac3991 100644 --- a/include/beast/websocket/impl/teardown.ipp +++ b/include/beast/websocket/impl/teardown.ipp @@ -9,8 +9,8 @@ #define BEAST_WEBSOCKET_IMPL_TEARDOWN_IPP #include -#include #include +#include #include #include @@ -22,9 +22,6 @@ namespace detail { template class teardown_tcp_op { - using alloc_type = - handler_alloc; - using socket_type = boost::asio::ip::tcp::socket; @@ -36,7 +33,7 @@ class teardown_tcp_op int state = 0; data(Handler& handler, socket_type& socket_) - : cont(boost_asio_handler_cont_helpers:: + : cont(beast_asio_helpers:: is_continuation(handler)) , socket(socket_) { @@ -64,7 +61,7 @@ public: void* asio_handler_allocate(std::size_t size, teardown_tcp_op* op) { - return boost_asio_handler_alloc_helpers:: + return beast_asio_helpers:: allocate(size, op->d_.handler()); } @@ -72,7 +69,7 @@ public: void asio_handler_deallocate(void* p, std::size_t size, teardown_tcp_op* op) { - return boost_asio_handler_alloc_helpers:: + return beast_asio_helpers:: deallocate(p, size, op->d_.handler()); } @@ -87,7 +84,7 @@ public: void asio_handler_invoke(Function&& f, teardown_tcp_op* op) { - return boost_asio_handler_invoke_helpers:: + return beast_asio_helpers:: invoke(f, op->d_.handler()); } }; diff --git a/include/beast/websocket/impl/write.ipp b/include/beast/websocket/impl/write.ipp index 884e7c7d..48032314 100644 --- a/include/beast/websocket/impl/write.ipp +++ b/include/beast/websocket/impl/write.ipp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include @@ -115,7 +115,7 @@ class stream::write_frame_op data(Handler& handler_, stream& ws_, bool fin, Buffers const& bs) : handler(handler_) - , cont(boost_asio_handler_cont_helpers:: + , cont(beast_asio_helpers:: is_continuation(handler)) , ws(ws_) , cb(bs) @@ -135,7 +135,7 @@ class stream::write_frame_op fh.key = ws.maskgen_(); detail::prepare_key(key, fh.key); tmp_size = clamp(fh.len, ws.wr_buf_size_); - tmp = boost_asio_handler_alloc_helpers:: + tmp = beast_asio_helpers:: allocate(tmp_size, handler); remain = fh.len; } @@ -149,7 +149,7 @@ class stream::write_frame_op ~data() { if(tmp) - boost_asio_handler_alloc_helpers:: + beast_asio_helpers:: deallocate(tmp, tmp_size, handler); } }; @@ -183,7 +183,7 @@ public: void* asio_handler_allocate( std::size_t size, write_frame_op* op) { - return boost_asio_handler_alloc_helpers:: + return beast_asio_helpers:: allocate(size, op->d_.handler()); } @@ -191,7 +191,7 @@ public: void asio_handler_deallocate( void* p, std::size_t size, write_frame_op* op) { - return boost_asio_handler_alloc_helpers:: + return beast_asio_helpers:: deallocate(p, size, op->d_.handler()); } @@ -205,7 +205,7 @@ public: friend void asio_handler_invoke(Function&& f, write_frame_op* op) { - return boost_asio_handler_invoke_helpers:: + return beast_asio_helpers:: invoke(f, op->d_.handler()); } }; @@ -533,7 +533,7 @@ class stream::write_op data(Handler& handler, stream& ws_, Buffers const& bs) - : cont(boost_asio_handler_cont_helpers:: + : cont(beast_asio_helpers:: is_continuation(handler)) , ws(ws_) , cb(bs) @@ -565,7 +565,7 @@ public: void* asio_handler_allocate( std::size_t size, write_op* op) { - return boost_asio_handler_alloc_helpers:: + return beast_asio_helpers:: allocate(size, op->d_.handler()); } @@ -573,7 +573,7 @@ public: void asio_handler_deallocate( void* p, std::size_t size, write_op* op) { - return boost_asio_handler_alloc_helpers:: + return beast_asio_helpers:: deallocate(p, size, op->d_.handler()); } @@ -587,7 +587,7 @@ public: friend void asio_handler_invoke(Function&& f, write_op* op) { - return boost_asio_handler_invoke_helpers:: + return beast_asio_helpers:: invoke(f, op->d_.handler()); } };