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

+39 -26
View File
@@ -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();
}
+15 -10
View File
@@ -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()));
}
};
+15 -10
View File
@@ -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()));
}
};
+15 -10
View File
@@ -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()));
}
};
+27 -19
View File
@@ -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()));
}
};
+15 -10
View File
@@ -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()));
}
};
+15 -10
View File
@@ -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()));
}
};
+28 -22
View File
@@ -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()));
}
};