Remove handler helpers, tidy up hook invocations (API Change)

This commit is contained in:
Vinnie Falco committed 2017-07-20 08:12:17 -07:00
1 parent 68a0f3af4f
commit 71e4fbe428
21 files changed
+315 -380

No files matched your search

@@ -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()));
}
};
+18 -12
View File
@@ -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)...);
}