mirror of
https://github.com/boostorg/beast.git
synced 2025-07-30 21:07:26 +02:00
Remove handler helpers, tidy up hook invocations (API Change)
This commit is contained in:
@ -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
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
47
doc/core.qbk
47
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]
|
||||
|
||||
|
||||
|
@ -207,13 +207,6 @@
|
||||
</simplelist>
|
||||
</entry>
|
||||
<entry valign="top">
|
||||
<bridgehead renderas="sect3">Helpers</bridgehead>
|
||||
<simplelist type="vert" columns="1">
|
||||
<member><link linkend="beast.ref.beast_asio_helpers__allocate">allocate</link></member>
|
||||
<member><link linkend="beast.ref.beast_asio_helpers__deallocate">deallocate</link></member>
|
||||
<member><link linkend="beast.ref.beast_asio_helpers__invoke">invoke</link></member>
|
||||
<member><link linkend="beast.ref.beast_asio_helpers__is_continuation">is_continuation</link></member>
|
||||
</simplelist>
|
||||
<bridgehead renderas="sect3">Concepts</bridgehead>
|
||||
<simplelist type="vert" columns="1">
|
||||
<member><link linkend="beast.ref.streams.AsyncStream">AsyncStream</link></member>
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "mime_type.hpp"
|
||||
|
||||
#include <beast/http.hpp>
|
||||
#include <beast/core/handler_helpers.hpp>
|
||||
#include <beast/core/handler_ptr.hpp>
|
||||
#include <beast/core/multi_buffer.hpp>
|
||||
#include <boost/asio.hpp>
|
||||
@ -98,11 +97,11 @@ private:
|
||||
|
||||
data(Handler& handler, Stream& s_,
|
||||
message<isRequest, Body, Fields>&& 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()));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include <beast/core/error.hpp>
|
||||
#include <beast/core/flat_buffer.hpp>
|
||||
#include <beast/core/handler_alloc.hpp>
|
||||
#include <beast/core/handler_helpers.hpp>
|
||||
#include <beast/core/handler_ptr.hpp>
|
||||
#include <beast/core/multi_buffer.hpp>
|
||||
#include <beast/core/ostream.hpp>
|
||||
|
@ -8,8 +8,10 @@
|
||||
#ifndef BEAST_BIND_DETAIL_HANDLER_HPP
|
||||
#define BEAST_BIND_DETAIL_HANDLER_HPP
|
||||
|
||||
#include <beast/core/handler_helpers.hpp>
|
||||
#include <beast/core/detail/integer_sequence.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <utility>
|
||||
|
||||
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<class F>
|
||||
@ -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_));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
#define BEAST_HANDLER_ALLOC_HPP
|
||||
|
||||
#include <beast/config.hpp>
|
||||
#include <beast/core/handler_helpers.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <cstdlib>
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
@ -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<value_type*>(
|
||||
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
|
||||
|
@ -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 <beast/config.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <memory>
|
||||
|
||||
/* 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 <class Handler>
|
||||
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<class Handler>
|
||||
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<class Function, class Handler>
|
||||
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<class Function, class Handler>
|
||||
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<class Handler>
|
||||
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
|
@ -10,9 +10,11 @@
|
||||
|
||||
#include <beast/core/bind_handler.hpp>
|
||||
#include <beast/core/error.hpp>
|
||||
#include <beast/core/handler_helpers.hpp>
|
||||
#include <beast/core/handler_ptr.hpp>
|
||||
#include <beast/core/type_traits.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
|
||||
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<class Function>
|
||||
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()));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -8,8 +8,9 @@
|
||||
#ifndef BEAST_IMPL_HANDLER_PTR_HPP
|
||||
#define BEAST_IMPL_HANDLER_PTR_HPP
|
||||
|
||||
#include <beast/core/handler_helpers.hpp>
|
||||
#include <boost/asio/detail/handler_alloc_helpers.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <memory>
|
||||
|
||||
@ -23,9 +24,10 @@ P(DeducedHandler&& h, Args&&... args)
|
||||
: n(1)
|
||||
, handler(std::forward<DeducedHandler>(h))
|
||||
{
|
||||
using boost::asio::asio_handler_allocate;
|
||||
t = reinterpret_cast<T*>(
|
||||
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<T, Handler>::
|
||||
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>(args)...);
|
||||
}
|
||||
|
@ -13,9 +13,11 @@
|
||||
#include <beast/http/message_parser.hpp>
|
||||
#include <beast/http/read.hpp>
|
||||
#include <beast/core/bind_handler.hpp>
|
||||
#include <beast/core/handler_helpers.hpp>
|
||||
#include <beast/core/handler_ptr.hpp>
|
||||
#include <beast/core/type_traits.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
@ -43,12 +45,12 @@ class read_some_buffer_op
|
||||
|
||||
data(Handler& handler, Stream& s_, DynamicBuffer& db_,
|
||||
basic_parser<isRequest, isDirect, Derived>& 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<isRequest, true, Derived>& 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<isRequest, isDirect, Derived>& 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()));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -13,9 +13,11 @@
|
||||
#include <beast/http/message_parser.hpp>
|
||||
#include <beast/http/read.hpp>
|
||||
#include <beast/core/bind_handler.hpp>
|
||||
#include <beast/core/handler_helpers.hpp>
|
||||
#include <beast/core/handler_ptr.hpp>
|
||||
#include <beast/core/type_traits.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
|
@ -13,11 +13,13 @@
|
||||
#include <beast/core/buffer_cat.hpp>
|
||||
#include <beast/core/bind_handler.hpp>
|
||||
#include <beast/core/ostream.hpp>
|
||||
#include <beast/core/handler_helpers.hpp>
|
||||
#include <beast/core/handler_ptr.hpp>
|
||||
#include <beast/core/multi_buffer.hpp>
|
||||
#include <beast/core/type_traits.hpp>
|
||||
#include <beast/core/detail/sync_ostream.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/asio/write.hpp>
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
@ -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<isRequest, Body, Fields> 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()));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -15,9 +15,11 @@
|
||||
#include <beast/http/string_body.hpp>
|
||||
#include <beast/http/write.hpp>
|
||||
#include <beast/core/buffer_prefix.hpp>
|
||||
#include <beast/core/handler_helpers.hpp>
|
||||
#include <beast/core/handler_ptr.hpp>
|
||||
#include <beast/core/detail/type_traits.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
@ -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<NextLayer>::accept_op
|
||||
|
||||
data(Handler& handler, stream<NextLayer>& 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<class Buffers>
|
||||
data(Handler& handler, stream<NextLayer>& 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<true, Fields> const& req,
|
||||
async_completion<AcceptHandler,
|
||||
void(error_code)> init{handler};
|
||||
reset();
|
||||
using boost::asio::asio_handler_is_continuation;
|
||||
response_op<handler_type<
|
||||
AcceptHandler, void(error_code)>>{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<true, Fields> const& req,
|
||||
async_completion<AcceptHandler,
|
||||
void(error_code)> init{handler};
|
||||
reset();
|
||||
using boost::asio::asio_handler_is_continuation;
|
||||
response_op<handler_type<
|
||||
AcceptHandler, void(error_code)>>{
|
||||
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<true, Fields> const& req,
|
||||
async_completion<AcceptHandler,
|
||||
void(error_code)> init{handler};
|
||||
reset();
|
||||
using boost::asio::asio_handler_is_continuation;
|
||||
response_op<handler_type<
|
||||
AcceptHandler, void(error_code)>>{
|
||||
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<true, Fields> const& req,
|
||||
async_completion<AcceptHandler,
|
||||
void(error_code)> init{handler};
|
||||
reset();
|
||||
using boost::asio::asio_handler_is_continuation;
|
||||
response_op<handler_type<
|
||||
AcceptHandler, void(error_code)>>{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();
|
||||
}
|
||||
|
||||
|
@ -8,10 +8,12 @@
|
||||
#ifndef BEAST_WEBSOCKET_IMPL_CLOSE_IPP
|
||||
#define BEAST_WEBSOCKET_IMPL_CLOSE_IPP
|
||||
|
||||
#include <beast/core/handler_helpers.hpp>
|
||||
#include <beast/core/handler_ptr.hpp>
|
||||
#include <beast/core/static_buffer.hpp>
|
||||
#include <beast/core/type_traits.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace beast {
|
||||
@ -37,11 +39,11 @@ class stream<NextLayer>::close_op
|
||||
|
||||
data(Handler& handler, stream<NextLayer>& 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()));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -12,9 +12,11 @@
|
||||
#include <beast/http/message.hpp>
|
||||
#include <beast/http/read.hpp>
|
||||
#include <beast/http/write.hpp>
|
||||
#include <beast/core/handler_helpers.hpp>
|
||||
#include <beast/core/handler_ptr.hpp>
|
||||
#include <beast/core/type_traits.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <memory>
|
||||
|
||||
@ -45,13 +47,13 @@ class stream<NextLayer>::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()));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -9,10 +9,12 @@
|
||||
#define BEAST_WEBSOCKET_IMPL_PING_IPP
|
||||
|
||||
#include <beast/core/bind_handler.hpp>
|
||||
#include <beast/core/handler_helpers.hpp>
|
||||
#include <beast/core/handler_ptr.hpp>
|
||||
#include <beast/core/type_traits.hpp>
|
||||
#include <beast/websocket/detail/frame.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace beast {
|
||||
@ -35,10 +37,10 @@ class stream<NextLayer>::ping_op
|
||||
|
||||
data(Handler& handler, stream<NextLayer>& 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()));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -10,11 +10,13 @@
|
||||
|
||||
#include <beast/websocket/teardown.hpp>
|
||||
#include <beast/core/buffer_prefix.hpp>
|
||||
#include <beast/core/handler_helpers.hpp>
|
||||
#include <beast/core/handler_ptr.hpp>
|
||||
#include <beast/core/static_buffer.hpp>
|
||||
#include <beast/core/type_traits.hpp>
|
||||
#include <beast/core/detail/clamp.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <limits>
|
||||
@ -57,12 +59,12 @@ class stream<NextLayer>::read_frame_op
|
||||
|
||||
data(Handler& handler, stream<NextLayer>& 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<NextLayer>::read_op
|
||||
data(Handler& handler,
|
||||
stream<NextLayer>& 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()));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -9,9 +9,11 @@
|
||||
#define BEAST_WEBSOCKET_IMPL_SSL_IPP_INCLUDED
|
||||
|
||||
#include <beast/core/async_result.hpp>
|
||||
#include <beast/core/handler_helpers.hpp>
|
||||
#include <beast/core/handler_ptr.hpp>
|
||||
#include <beast/core/type_traits.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
|
||||
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()));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -9,9 +9,11 @@
|
||||
#define BEAST_WEBSOCKET_IMPL_TEARDOWN_IPP
|
||||
|
||||
#include <beast/core/async_result.hpp>
|
||||
#include <beast/core/handler_helpers.hpp>
|
||||
#include <beast/core/handler_ptr.hpp>
|
||||
#include <beast/core/type_traits.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <memory>
|
||||
|
||||
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()));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -12,12 +12,14 @@
|
||||
#include <beast/core/buffer_cat.hpp>
|
||||
#include <beast/core/buffer_prefix.hpp>
|
||||
#include <beast/core/consuming_buffers.hpp>
|
||||
#include <beast/core/handler_helpers.hpp>
|
||||
#include <beast/core/handler_ptr.hpp>
|
||||
#include <beast/core/static_buffer.hpp>
|
||||
#include <beast/core/type_traits.hpp>
|
||||
#include <beast/core/detail/clamp.hpp>
|
||||
#include <beast/websocket/detail/frame.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
@ -31,7 +33,6 @@ class stream<NextLayer>::write_frame_op
|
||||
{
|
||||
struct data : op
|
||||
{
|
||||
Handler& handler;
|
||||
bool cont;
|
||||
stream<NextLayer>& ws;
|
||||
consuming_buffers<Buffers> cb;
|
||||
@ -43,15 +44,14 @@ class stream<NextLayer>::write_frame_op
|
||||
int state = 0;
|
||||
int entry_state;
|
||||
|
||||
data(Handler& handler_, stream<NextLayer>& ws_,
|
||||
data(Handler& handler, stream<NextLayer>& 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<NextLayer>::write_op
|
||||
|
||||
data(Handler& handler, stream<NextLayer>& 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()));
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user