forked from boostorg/beast
Update for Net-TS Asio (API Change):
fix #769 The following classes are removed: * handler_type * async_result * async_completion * is_dynamic_buffer * is_const_buffer_sequence * is_mutable_buffer_sequence * handler_alloc Actions Required: * Use BOOST_ASIO_HANDLER_TYPE instead of handler_type * Use BOOST_ASIO_INITFN_RESULT_TYPE instead of async_result * Use boost::asio::async_completion * Use boost::asio::is_dynamic_buffer * Use boost::asio::is_const_buffer_sequence * Use boost::asio::is_mutable_buffer_sequence * boost::asio::associated_allocator_t replaces handler_alloc
This commit is contained in:
1 parent
9dc9ca13b9
commit
3a28e999af
173 files changed
+3214
-4138
No files matched your search
@@ -20,9 +20,10 @@
|
||||
#include <boost/beast/core/handler_ptr.hpp>
|
||||
#include <boost/beast/core/detail/type_traits.hpp>
|
||||
#include <boost/asio/coroutine.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/associated_allocator.hpp>
|
||||
#include <boost/asio/associated_executor.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/asio/post.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <memory>
|
||||
@@ -67,28 +68,28 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
using allocator_type =
|
||||
boost::asio::associated_allocator_t<Handler>;
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_allocator(d_.handler());
|
||||
}
|
||||
|
||||
using executor_type = boost::asio::associated_executor_t<
|
||||
Handler, decltype(d_->ws.get_executor())>;
|
||||
|
||||
executor_type get_executor() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_executor(
|
||||
d_.handler(), d_->ws.get_executor());
|
||||
}
|
||||
|
||||
void operator()(
|
||||
error_code ec = {},
|
||||
std::size_t bytes_transferred = 0);
|
||||
|
||||
friend
|
||||
void* asio_handler_allocate(
|
||||
std::size_t size, response_op* op)
|
||||
{
|
||||
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)
|
||||
{
|
||||
using boost::asio::asio_handler_deallocate;
|
||||
asio_handler_deallocate(
|
||||
p, size, std::addressof(op->d_.handler()));
|
||||
}
|
||||
|
||||
friend
|
||||
bool asio_handler_is_continuation(response_op* op)
|
||||
{
|
||||
@@ -96,15 +97,6 @@ public:
|
||||
return asio_handler_is_continuation(
|
||||
std::addressof(op->d_.handler()));
|
||||
}
|
||||
|
||||
template<class Function>
|
||||
friend
|
||||
void asio_handler_invoke(Function&& f, response_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_invoke;
|
||||
asio_handler_invoke(
|
||||
f, std::addressof(op->d_.handler()));
|
||||
}
|
||||
};
|
||||
|
||||
template<class NextLayer>
|
||||
@@ -171,6 +163,24 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
using allocator_type =
|
||||
boost::asio::associated_allocator_t<Handler>;
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_allocator(d_.handler());
|
||||
}
|
||||
|
||||
using executor_type = boost::asio::associated_executor_t<
|
||||
Handler, decltype(d_->ws.get_executor())>;
|
||||
|
||||
executor_type get_executor() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_executor(
|
||||
d_.handler(), d_->ws.get_executor());
|
||||
}
|
||||
|
||||
template<class Buffers>
|
||||
void run(Buffers const& buffers);
|
||||
|
||||
@@ -178,24 +188,6 @@ public:
|
||||
error_code ec = {},
|
||||
std::size_t bytes_used = 0);
|
||||
|
||||
friend
|
||||
void* asio_handler_allocate(
|
||||
std::size_t size, accept_op* op)
|
||||
{
|
||||
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)
|
||||
{
|
||||
using boost::asio::asio_handler_deallocate;
|
||||
asio_handler_deallocate(
|
||||
p, size, std::addressof(op->d_.handler()));
|
||||
}
|
||||
|
||||
friend
|
||||
bool asio_handler_is_continuation(accept_op* op)
|
||||
{
|
||||
@@ -203,15 +195,6 @@ public:
|
||||
return asio_handler_is_continuation(
|
||||
std::addressof(op->d_.handler()));
|
||||
}
|
||||
|
||||
template<class Function>
|
||||
friend
|
||||
void asio_handler_invoke(Function&& f, accept_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_invoke;
|
||||
asio_handler_invoke(
|
||||
f, std::addressof(op->d_.handler()));
|
||||
}
|
||||
};
|
||||
|
||||
template<class NextLayer>
|
||||
@@ -256,7 +239,8 @@ operator()(error_code ec, std::size_t)
|
||||
if(ec)
|
||||
{
|
||||
BOOST_ASIO_CORO_YIELD
|
||||
d.ws.get_io_service().post(
|
||||
boost::asio::post(
|
||||
d.ws.get_executor(),
|
||||
bind_handler(std::move(*this), ec));
|
||||
}
|
||||
else
|
||||
@@ -269,7 +253,7 @@ operator()(error_code ec, std::size_t)
|
||||
ec = error::closed;
|
||||
if(! ec)
|
||||
{
|
||||
// Arguments from our step must be
|
||||
// Arguments from our state must be
|
||||
// moved to the stack before releasing
|
||||
// the handler.
|
||||
auto& ws = d.ws;
|
||||
@@ -359,7 +343,7 @@ accept(ConstBufferSequence const& buffers)
|
||||
{
|
||||
static_assert(is_sync_stream<next_layer_type>::value,
|
||||
"SyncStream requirements not met");
|
||||
static_assert(is_const_buffer_sequence<
|
||||
static_assert(boost::asio::is_const_buffer_sequence<
|
||||
ConstBufferSequence>::value,
|
||||
"ConstBufferSequence requirements not met");
|
||||
error_code ec;
|
||||
@@ -381,7 +365,7 @@ accept_ex(
|
||||
{
|
||||
static_assert(is_sync_stream<next_layer_type>::value,
|
||||
"SyncStream requirements not met");
|
||||
static_assert(is_const_buffer_sequence<
|
||||
static_assert(boost::asio::is_const_buffer_sequence<
|
||||
ConstBufferSequence>::value,
|
||||
"ConstBufferSequence requirements not met");
|
||||
static_assert(detail::is_ResponseDecorator<
|
||||
@@ -403,7 +387,7 @@ accept(
|
||||
{
|
||||
static_assert(is_sync_stream<next_layer_type>::value,
|
||||
"SyncStream requirements not met");
|
||||
static_assert(is_const_buffer_sequence<
|
||||
static_assert(boost::asio::is_const_buffer_sequence<
|
||||
ConstBufferSequence>::value,
|
||||
"ConstBufferSequence requirements not met");
|
||||
using boost::asio::buffer_copy;
|
||||
@@ -440,10 +424,10 @@ accept_ex(
|
||||
{
|
||||
static_assert(is_sync_stream<next_layer_type>::value,
|
||||
"SyncStream requirements not met");
|
||||
static_assert(is_const_buffer_sequence<
|
||||
static_assert(boost::asio::is_const_buffer_sequence<
|
||||
ConstBufferSequence>::value,
|
||||
"ConstBufferSequence requirements not met");
|
||||
static_assert(is_const_buffer_sequence<
|
||||
static_assert(boost::asio::is_const_buffer_sequence<
|
||||
ConstBufferSequence>::value,
|
||||
"ConstBufferSequence requirements not met");
|
||||
using boost::asio::buffer_copy;
|
||||
@@ -544,22 +528,24 @@ accept_ex(
|
||||
template<class NextLayer>
|
||||
template<
|
||||
class AcceptHandler>
|
||||
async_return_type<AcceptHandler, void(error_code)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
AcceptHandler, void(error_code))
|
||||
stream<NextLayer>::
|
||||
async_accept(
|
||||
AcceptHandler&& handler)
|
||||
{
|
||||
static_assert(is_async_stream<next_layer_type>::value,
|
||||
"AsyncStream requirements requirements not met");
|
||||
async_completion<AcceptHandler,
|
||||
boost::asio::async_completion<AcceptHandler,
|
||||
void(error_code)> init{handler};
|
||||
reset();
|
||||
accept_op<
|
||||
decltype(&default_decorate_res),
|
||||
handler_type<AcceptHandler, void(error_code)>>{
|
||||
init.completion_handler,
|
||||
*this,
|
||||
&default_decorate_res}({});
|
||||
BOOST_ASIO_HANDLER_TYPE(
|
||||
AcceptHandler, void(error_code))>{
|
||||
init.completion_handler,
|
||||
*this,
|
||||
&default_decorate_res}({});
|
||||
return init.result.get();
|
||||
}
|
||||
|
||||
@@ -567,7 +553,8 @@ template<class NextLayer>
|
||||
template<
|
||||
class ResponseDecorator,
|
||||
class AcceptHandler>
|
||||
async_return_type<AcceptHandler, void(error_code)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
AcceptHandler, void(error_code))
|
||||
stream<NextLayer>::
|
||||
async_accept_ex(
|
||||
ResponseDecorator const& decorator,
|
||||
@@ -578,15 +565,16 @@ async_accept_ex(
|
||||
static_assert(detail::is_ResponseDecorator<
|
||||
ResponseDecorator>::value,
|
||||
"ResponseDecorator requirements not met");
|
||||
async_completion<AcceptHandler,
|
||||
boost::asio::async_completion<AcceptHandler,
|
||||
void(error_code)> init{handler};
|
||||
reset();
|
||||
accept_op<
|
||||
ResponseDecorator,
|
||||
handler_type<AcceptHandler, void(error_code)>>{
|
||||
init.completion_handler,
|
||||
*this,
|
||||
decorator}({});
|
||||
BOOST_ASIO_HANDLER_TYPE(
|
||||
AcceptHandler, void(error_code))>{
|
||||
init.completion_handler,
|
||||
*this,
|
||||
decorator}({});
|
||||
return init.result.get();
|
||||
}
|
||||
|
||||
@@ -596,7 +584,8 @@ template<
|
||||
class AcceptHandler>
|
||||
typename std::enable_if<
|
||||
! http::detail::is_header<ConstBufferSequence>::value,
|
||||
async_return_type<AcceptHandler, void(error_code)>>::type
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
AcceptHandler, void(error_code))>::type
|
||||
stream<NextLayer>::
|
||||
async_accept(
|
||||
ConstBufferSequence const& buffers,
|
||||
@@ -604,18 +593,19 @@ async_accept(
|
||||
{
|
||||
static_assert(is_async_stream<next_layer_type>::value,
|
||||
"AsyncStream requirements requirements not met");
|
||||
static_assert(is_const_buffer_sequence<
|
||||
static_assert(boost::asio::is_const_buffer_sequence<
|
||||
ConstBufferSequence>::value,
|
||||
"ConstBufferSequence requirements not met");
|
||||
async_completion<AcceptHandler,
|
||||
boost::asio::async_completion<AcceptHandler,
|
||||
void(error_code)> init{handler};
|
||||
reset();
|
||||
accept_op<
|
||||
decltype(&default_decorate_res),
|
||||
handler_type<AcceptHandler, void(error_code)>>{
|
||||
init.completion_handler,
|
||||
*this,
|
||||
&default_decorate_res}.run(buffers);
|
||||
BOOST_ASIO_HANDLER_TYPE(
|
||||
AcceptHandler, void(error_code))>{
|
||||
init.completion_handler,
|
||||
*this,
|
||||
&default_decorate_res}.run(buffers);
|
||||
return init.result.get();
|
||||
}
|
||||
|
||||
@@ -626,7 +616,8 @@ template<
|
||||
class AcceptHandler>
|
||||
typename std::enable_if<
|
||||
! http::detail::is_header<ConstBufferSequence>::value,
|
||||
async_return_type<AcceptHandler, void(error_code)>>::type
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
AcceptHandler, void(error_code))>::type
|
||||
stream<NextLayer>::
|
||||
async_accept_ex(
|
||||
ConstBufferSequence const& buffers,
|
||||
@@ -635,21 +626,22 @@ async_accept_ex(
|
||||
{
|
||||
static_assert(is_async_stream<next_layer_type>::value,
|
||||
"AsyncStream requirements requirements not met");
|
||||
static_assert(is_const_buffer_sequence<
|
||||
static_assert(boost::asio::is_const_buffer_sequence<
|
||||
ConstBufferSequence>::value,
|
||||
"ConstBufferSequence requirements not met");
|
||||
static_assert(detail::is_ResponseDecorator<
|
||||
ResponseDecorator>::value,
|
||||
"ResponseDecorator requirements not met");
|
||||
async_completion<AcceptHandler,
|
||||
boost::asio::async_completion<AcceptHandler,
|
||||
void(error_code)> init{handler};
|
||||
reset();
|
||||
accept_op<
|
||||
ResponseDecorator,
|
||||
handler_type<AcceptHandler, void(error_code)>>{
|
||||
init.completion_handler,
|
||||
*this,
|
||||
decorator}.run(buffers);
|
||||
BOOST_ASIO_HANDLER_TYPE(
|
||||
AcceptHandler, void(error_code))>{
|
||||
init.completion_handler,
|
||||
*this,
|
||||
decorator}.run(buffers);
|
||||
return init.result.get();
|
||||
}
|
||||
|
||||
@@ -657,7 +649,8 @@ template<class NextLayer>
|
||||
template<
|
||||
class Body, class Allocator,
|
||||
class AcceptHandler>
|
||||
async_return_type<AcceptHandler, void(error_code)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
AcceptHandler, void(error_code))
|
||||
stream<NextLayer>::
|
||||
async_accept(
|
||||
http::request<Body, http::basic_fields<Allocator>> const& req,
|
||||
@@ -665,16 +658,17 @@ async_accept(
|
||||
{
|
||||
static_assert(is_async_stream<next_layer_type>::value,
|
||||
"AsyncStream requirements requirements not met");
|
||||
async_completion<AcceptHandler,
|
||||
boost::asio::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}();
|
||||
BOOST_ASIO_HANDLER_TYPE(
|
||||
AcceptHandler, void(error_code))>{
|
||||
init.completion_handler,
|
||||
*this,
|
||||
req,
|
||||
&default_decorate_res}();
|
||||
return init.result.get();
|
||||
}
|
||||
|
||||
@@ -683,7 +677,8 @@ template<
|
||||
class Body, class Allocator,
|
||||
class ResponseDecorator,
|
||||
class AcceptHandler>
|
||||
async_return_type<AcceptHandler, void(error_code)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
AcceptHandler, void(error_code))
|
||||
stream<NextLayer>::
|
||||
async_accept_ex(
|
||||
http::request<Body, http::basic_fields<Allocator>> const& req,
|
||||
@@ -695,16 +690,17 @@ async_accept_ex(
|
||||
static_assert(detail::is_ResponseDecorator<
|
||||
ResponseDecorator>::value,
|
||||
"ResponseDecorator requirements not met");
|
||||
async_completion<AcceptHandler,
|
||||
boost::asio::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}();
|
||||
BOOST_ASIO_HANDLER_TYPE(
|
||||
AcceptHandler, void(error_code))>{
|
||||
init.completion_handler,
|
||||
*this,
|
||||
req,
|
||||
decorator}();
|
||||
return init.result.get();
|
||||
}
|
||||
|
||||
|
||||
@@ -15,10 +15,11 @@
|
||||
#include <boost/beast/core/flat_static_buffer.hpp>
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
#include <boost/beast/core/detail/config.hpp>
|
||||
#include <boost/asio/associated_allocator.hpp>
|
||||
#include <boost/asio/associated_executor.hpp>
|
||||
#include <boost/asio/coroutine.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/post.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <memory>
|
||||
|
||||
@@ -74,30 +75,30 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
using allocator_type =
|
||||
boost::asio::associated_allocator_t<Handler>;
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_allocator(d_.handler());
|
||||
}
|
||||
|
||||
using executor_type = boost::asio::associated_executor_t<
|
||||
Handler, decltype(d_->ws.get_executor())>;
|
||||
|
||||
executor_type get_executor() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_executor(
|
||||
d_.handler(), d_->ws.get_executor());
|
||||
}
|
||||
|
||||
void
|
||||
operator()(
|
||||
error_code ec = {},
|
||||
std::size_t bytes_transferred = 0,
|
||||
bool cont = true);
|
||||
|
||||
friend
|
||||
void* asio_handler_allocate(
|
||||
std::size_t size, close_op* op)
|
||||
{
|
||||
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)
|
||||
{
|
||||
using boost::asio::asio_handler_deallocate;
|
||||
asio_handler_deallocate(
|
||||
p, size, std::addressof(op->d_.handler()));
|
||||
}
|
||||
|
||||
friend
|
||||
bool asio_handler_is_continuation(close_op* op)
|
||||
{
|
||||
@@ -105,15 +106,6 @@ public:
|
||||
return op->d_->cont || asio_handler_is_continuation(
|
||||
std::addressof(op->d_.handler()));
|
||||
}
|
||||
|
||||
template<class Function>
|
||||
friend
|
||||
void asio_handler_invoke(Function&& f, close_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_invoke;
|
||||
asio_handler_invoke(
|
||||
f, std::addressof(op->d_.handler()));
|
||||
}
|
||||
};
|
||||
|
||||
template<class NextLayer>
|
||||
@@ -155,7 +147,8 @@ operator()(
|
||||
|
||||
// Resume
|
||||
BOOST_ASIO_CORO_YIELD
|
||||
d.ws.get_io_service().post(std::move(*this));
|
||||
boost::asio::post(
|
||||
d.ws.get_executor(), std::move(*this));
|
||||
BOOST_ASSERT(d.ws.wr_block_ == d.tok);
|
||||
|
||||
// Make sure the stream is open
|
||||
@@ -205,7 +198,8 @@ operator()(
|
||||
|
||||
// Resume
|
||||
BOOST_ASIO_CORO_YIELD
|
||||
d.ws.get_io_service().post(std::move(*this));
|
||||
boost::asio::post(
|
||||
d.ws.get_executor(), std::move(*this));
|
||||
BOOST_ASSERT(d.ws.rd_block_ == d.tok);
|
||||
|
||||
// Make sure the stream is open
|
||||
@@ -322,7 +316,8 @@ operator()(
|
||||
if(! d.cont)
|
||||
{
|
||||
auto& ws = d.ws;
|
||||
return ws.stream_.get_io_service().post(
|
||||
return boost::asio::post(
|
||||
ws.stream_.get_executor(),
|
||||
bind_handler(d_.release_handler(), ec));
|
||||
}
|
||||
d_.invoke(ec);
|
||||
@@ -440,17 +435,17 @@ close(close_reason const& cr, error_code& ec)
|
||||
|
||||
template<class NextLayer>
|
||||
template<class CloseHandler>
|
||||
async_return_type<
|
||||
CloseHandler, void(error_code)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
CloseHandler, void(error_code))
|
||||
stream<NextLayer>::
|
||||
async_close(close_reason const& cr, CloseHandler&& handler)
|
||||
{
|
||||
static_assert(is_async_stream<next_layer_type>::value,
|
||||
"AsyncStream requirements not met");
|
||||
async_completion<CloseHandler,
|
||||
boost::asio::async_completion<CloseHandler,
|
||||
void(error_code)> init{handler};
|
||||
close_op<handler_type<
|
||||
CloseHandler, void(error_code)>>{
|
||||
close_op<BOOST_ASIO_HANDLER_TYPE(
|
||||
CloseHandler, void(error_code))>{
|
||||
init.completion_handler, *this, cr}(
|
||||
{}, 0, false);
|
||||
return init.result.get();
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
#include <boost/beast/http/write.hpp>
|
||||
#include <boost/beast/core/handler_ptr.hpp>
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
#include <boost/asio/associated_allocator.hpp>
|
||||
#include <boost/asio/associated_executor.hpp>
|
||||
#include <boost/asio/coroutine.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/throw_exception.hpp>
|
||||
#include <memory>
|
||||
@@ -75,29 +75,29 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
using allocator_type =
|
||||
boost::asio::associated_allocator_t<Handler>;
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_allocator(d_.handler());
|
||||
}
|
||||
|
||||
using executor_type = boost::asio::associated_executor_t<
|
||||
Handler, decltype(d_->ws.get_executor())>;
|
||||
|
||||
executor_type get_executor() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_executor(
|
||||
d_.handler(), d_->ws.get_executor());
|
||||
}
|
||||
|
||||
void
|
||||
operator()(
|
||||
error_code ec = {},
|
||||
std::size_t bytes_used = 0);
|
||||
|
||||
friend
|
||||
void* asio_handler_allocate(
|
||||
std::size_t size, handshake_op* op)
|
||||
{
|
||||
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)
|
||||
{
|
||||
using boost::asio::asio_handler_deallocate;
|
||||
asio_handler_deallocate(
|
||||
p, size, std::addressof(op->d_.handler()));
|
||||
}
|
||||
|
||||
friend
|
||||
bool asio_handler_is_continuation(handshake_op* op)
|
||||
{
|
||||
@@ -105,15 +105,6 @@ public:
|
||||
return asio_handler_is_continuation(
|
||||
std::addressof(op->d_.handler()));
|
||||
}
|
||||
|
||||
template<class Function>
|
||||
friend
|
||||
void asio_handler_invoke(Function&& f, handshake_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_invoke;
|
||||
asio_handler_invoke(
|
||||
f, std::addressof(op->d_.handler()));
|
||||
}
|
||||
};
|
||||
|
||||
template<class NextLayer>
|
||||
@@ -156,8 +147,8 @@ operator()(error_code ec, std::size_t)
|
||||
|
||||
template<class NextLayer>
|
||||
template<class HandshakeHandler>
|
||||
async_return_type<
|
||||
HandshakeHandler, void(error_code)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
HandshakeHandler, void(error_code))
|
||||
stream<NextLayer>::
|
||||
async_handshake(string_view host,
|
||||
string_view target,
|
||||
@@ -165,10 +156,10 @@ async_handshake(string_view host,
|
||||
{
|
||||
static_assert(is_async_stream<next_layer_type>::value,
|
||||
"AsyncStream requirements not met");
|
||||
async_completion<HandshakeHandler,
|
||||
boost::asio::async_completion<HandshakeHandler,
|
||||
void(error_code)> init{handler};
|
||||
handshake_op<handler_type<
|
||||
HandshakeHandler, void(error_code)>>{
|
||||
handshake_op<BOOST_ASIO_HANDLER_TYPE(
|
||||
HandshakeHandler, void(error_code))>{
|
||||
init.completion_handler, *this, nullptr, host,
|
||||
target, &default_decorate_req}();
|
||||
return init.result.get();
|
||||
@@ -176,8 +167,8 @@ async_handshake(string_view host,
|
||||
|
||||
template<class NextLayer>
|
||||
template<class HandshakeHandler>
|
||||
async_return_type<
|
||||
HandshakeHandler, void(error_code)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
HandshakeHandler, void(error_code))
|
||||
stream<NextLayer>::
|
||||
async_handshake(response_type& res,
|
||||
string_view host,
|
||||
@@ -186,10 +177,10 @@ async_handshake(response_type& res,
|
||||
{
|
||||
static_assert(is_async_stream<next_layer_type>::value,
|
||||
"AsyncStream requirements not met");
|
||||
async_completion<HandshakeHandler,
|
||||
boost::asio::async_completion<HandshakeHandler,
|
||||
void(error_code)> init{handler};
|
||||
handshake_op<handler_type<
|
||||
HandshakeHandler, void(error_code)>>{
|
||||
handshake_op<BOOST_ASIO_HANDLER_TYPE(
|
||||
HandshakeHandler, void(error_code))>{
|
||||
init.completion_handler, *this, &res, host,
|
||||
target, &default_decorate_req}();
|
||||
return init.result.get();
|
||||
@@ -197,8 +188,8 @@ async_handshake(response_type& res,
|
||||
|
||||
template<class NextLayer>
|
||||
template<class RequestDecorator, class HandshakeHandler>
|
||||
async_return_type<
|
||||
HandshakeHandler, void(error_code)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
HandshakeHandler, void(error_code))
|
||||
stream<NextLayer>::
|
||||
async_handshake_ex(string_view host,
|
||||
string_view target,
|
||||
@@ -210,10 +201,10 @@ async_handshake_ex(string_view host,
|
||||
static_assert(detail::is_RequestDecorator<
|
||||
RequestDecorator>::value,
|
||||
"RequestDecorator requirements not met");
|
||||
async_completion<HandshakeHandler,
|
||||
boost::asio::async_completion<HandshakeHandler,
|
||||
void(error_code)> init{handler};
|
||||
handshake_op<handler_type<
|
||||
HandshakeHandler, void(error_code)>>{
|
||||
handshake_op<BOOST_ASIO_HANDLER_TYPE(
|
||||
HandshakeHandler, void(error_code))>{
|
||||
init.completion_handler, *this, nullptr, host,
|
||||
target, decorator}();
|
||||
return init.result.get();
|
||||
@@ -221,8 +212,8 @@ async_handshake_ex(string_view host,
|
||||
|
||||
template<class NextLayer>
|
||||
template<class RequestDecorator, class HandshakeHandler>
|
||||
async_return_type<
|
||||
HandshakeHandler, void(error_code)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
HandshakeHandler, void(error_code))
|
||||
stream<NextLayer>::
|
||||
async_handshake_ex(response_type& res,
|
||||
string_view host,
|
||||
@@ -235,10 +226,10 @@ async_handshake_ex(response_type& res,
|
||||
static_assert(detail::is_RequestDecorator<
|
||||
RequestDecorator>::value,
|
||||
"RequestDecorator requirements not met");
|
||||
async_completion<HandshakeHandler,
|
||||
boost::asio::async_completion<HandshakeHandler,
|
||||
void(error_code)> init{handler};
|
||||
handshake_op<handler_type<
|
||||
HandshakeHandler, void(error_code)>>{
|
||||
handshake_op<BOOST_ASIO_HANDLER_TYPE(
|
||||
HandshakeHandler, void(error_code))>{
|
||||
init.completion_handler, *this, &res, host,
|
||||
target, decorator}();
|
||||
return init.result.get();
|
||||
|
||||
@@ -15,10 +15,11 @@
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
#include <boost/beast/core/detail/config.hpp>
|
||||
#include <boost/beast/websocket/detail/frame.hpp>
|
||||
#include <boost/asio/associated_allocator.hpp>
|
||||
#include <boost/asio/associated_executor.hpp>
|
||||
#include <boost/asio/coroutine.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/post.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <memory>
|
||||
|
||||
@@ -74,28 +75,28 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
using allocator_type =
|
||||
boost::asio::associated_allocator_t<Handler>;
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_allocator(d_.handler());
|
||||
}
|
||||
|
||||
using executor_type = boost::asio::associated_executor_t<
|
||||
Handler, decltype(d_->ws.get_executor())>;
|
||||
|
||||
executor_type get_executor() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_executor(
|
||||
d_.handler(), d_->ws.get_executor());
|
||||
}
|
||||
|
||||
void operator()(
|
||||
error_code ec = {},
|
||||
std::size_t bytes_transferred = 0);
|
||||
|
||||
friend
|
||||
void* asio_handler_allocate(
|
||||
std::size_t size, ping_op* op)
|
||||
{
|
||||
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)
|
||||
{
|
||||
using boost::asio::asio_handler_deallocate;
|
||||
asio_handler_deallocate(
|
||||
p, size, std::addressof(op->d_.handler()));
|
||||
}
|
||||
|
||||
friend
|
||||
bool asio_handler_is_continuation(ping_op* op)
|
||||
{
|
||||
@@ -103,15 +104,6 @@ public:
|
||||
return asio_handler_is_continuation(
|
||||
std::addressof(op->d_.handler()));
|
||||
}
|
||||
|
||||
template<class Function>
|
||||
friend
|
||||
void asio_handler_invoke(Function&& f, ping_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_invoke;
|
||||
asio_handler_invoke(
|
||||
f, std::addressof(op->d_.handler()));
|
||||
}
|
||||
};
|
||||
|
||||
template<class NextLayer>
|
||||
@@ -134,7 +126,8 @@ operator()(error_code ec, std::size_t)
|
||||
if(! d.ws.check_open(ec))
|
||||
{
|
||||
BOOST_ASIO_CORO_YIELD
|
||||
d.ws.get_io_service().post(
|
||||
boost::asio::post(
|
||||
d.ws.get_executor(),
|
||||
bind_handler(std::move(*this), ec));
|
||||
goto upcall;
|
||||
}
|
||||
@@ -152,7 +145,8 @@ operator()(error_code ec, std::size_t)
|
||||
|
||||
// Resume
|
||||
BOOST_ASIO_CORO_YIELD
|
||||
d.ws.get_io_service().post(std::move(*this));
|
||||
boost::asio::post(
|
||||
d.ws.get_executor(), std::move(*this));
|
||||
BOOST_ASSERT(d.ws.wr_block_ == d.tok);
|
||||
|
||||
// Make sure the stream is open
|
||||
@@ -235,17 +229,17 @@ pong(ping_data const& payload, error_code& ec)
|
||||
|
||||
template<class NextLayer>
|
||||
template<class WriteHandler>
|
||||
async_return_type<
|
||||
WriteHandler, void(error_code)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
WriteHandler, void(error_code))
|
||||
stream<NextLayer>::
|
||||
async_ping(ping_data const& payload, WriteHandler&& handler)
|
||||
{
|
||||
static_assert(is_async_stream<next_layer_type>::value,
|
||||
"AsyncStream requirements requirements not met");
|
||||
async_completion<WriteHandler,
|
||||
boost::asio::async_completion<WriteHandler,
|
||||
void(error_code)> init{handler};
|
||||
ping_op<handler_type<
|
||||
WriteHandler, void(error_code)>>{
|
||||
ping_op<BOOST_ASIO_HANDLER_TYPE(
|
||||
WriteHandler, void(error_code))>{
|
||||
init.completion_handler, *this,
|
||||
detail::opcode::ping, payload}();
|
||||
return init.result.get();
|
||||
@@ -253,17 +247,17 @@ async_ping(ping_data const& payload, WriteHandler&& handler)
|
||||
|
||||
template<class NextLayer>
|
||||
template<class WriteHandler>
|
||||
async_return_type<
|
||||
WriteHandler, void(error_code)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
WriteHandler, void(error_code))
|
||||
stream<NextLayer>::
|
||||
async_pong(ping_data const& payload, WriteHandler&& handler)
|
||||
{
|
||||
static_assert(is_async_stream<next_layer_type>::value,
|
||||
"AsyncStream requirements requirements not met");
|
||||
async_completion<WriteHandler,
|
||||
boost::asio::async_completion<WriteHandler,
|
||||
void(error_code)> init{handler};
|
||||
ping_op<handler_type<
|
||||
WriteHandler, void(error_code)>>{
|
||||
ping_op<BOOST_ASIO_HANDLER_TYPE(
|
||||
WriteHandler, void(error_code))>{
|
||||
init.completion_handler, *this,
|
||||
detail::opcode::pong, payload}();
|
||||
return init.result.get();
|
||||
|
||||
@@ -18,10 +18,11 @@
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
#include <boost/beast/core/detail/clamp.hpp>
|
||||
#include <boost/beast/core/detail/config.hpp>
|
||||
#include <boost/asio/associated_allocator.hpp>
|
||||
#include <boost/asio/associated_executor.hpp>
|
||||
#include <boost/asio/coroutine.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/post.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
@@ -74,6 +75,24 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
using allocator_type =
|
||||
boost::asio::associated_allocator_t<Handler>;
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_allocator(h_);
|
||||
}
|
||||
|
||||
using executor_type = boost::asio::associated_executor_t<
|
||||
Handler, decltype(ws_.get_executor())>;
|
||||
|
||||
executor_type get_executor() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_executor(
|
||||
h_, ws_.get_executor());
|
||||
}
|
||||
|
||||
Handler&
|
||||
handler()
|
||||
{
|
||||
@@ -85,24 +104,6 @@ public:
|
||||
std::size_t bytes_transferred = 0,
|
||||
bool cont = true);
|
||||
|
||||
friend
|
||||
void* asio_handler_allocate(
|
||||
std::size_t size, read_some_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_allocate;
|
||||
return asio_handler_allocate(
|
||||
size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
void asio_handler_deallocate(
|
||||
void* p, std::size_t size, read_some_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_deallocate;
|
||||
asio_handler_deallocate(p, size,
|
||||
std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
bool asio_handler_is_continuation(read_some_op* op)
|
||||
{
|
||||
@@ -110,15 +111,6 @@ public:
|
||||
return op->cont_ || asio_handler_is_continuation(
|
||||
std::addressof(op->h_));
|
||||
}
|
||||
|
||||
template<class Function>
|
||||
friend
|
||||
void asio_handler_invoke(Function&& f, read_some_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_invoke;
|
||||
asio_handler_invoke(
|
||||
f, std::addressof(op->h_));
|
||||
}
|
||||
};
|
||||
|
||||
template<class NextLayer>
|
||||
@@ -133,7 +125,6 @@ operator()(
|
||||
{
|
||||
using beast::detail::clamp;
|
||||
using boost::asio::buffer;
|
||||
using boost::asio::buffer_cast;
|
||||
using boost::asio::buffer_size;
|
||||
close_code code{};
|
||||
cont_ = cont;
|
||||
@@ -168,7 +159,8 @@ operator()(
|
||||
|
||||
// Resume
|
||||
BOOST_ASIO_CORO_YIELD
|
||||
ws_.get_io_service().post(std::move(*this));
|
||||
boost::asio::post(
|
||||
ws_.get_executor(), std::move(*this));
|
||||
BOOST_ASSERT(ws_.rd_block_ == tok_);
|
||||
|
||||
// The only way to get read blocked is if
|
||||
@@ -290,7 +282,8 @@ operator()(
|
||||
|
||||
// Resume
|
||||
BOOST_ASIO_CORO_YIELD
|
||||
ws_.get_io_service().post(std::move(*this));
|
||||
boost::asio::post(
|
||||
ws_.get_executor(), std::move(*this));
|
||||
BOOST_ASSERT(ws_.wr_block_ == tok_);
|
||||
|
||||
// Make sure the stream is open
|
||||
@@ -489,8 +482,8 @@ operator()(
|
||||
zlib::z_params zs;
|
||||
{
|
||||
auto const out = buffers_front(cb_);
|
||||
zs.next_out = buffer_cast<void*>(out);
|
||||
zs.avail_out = buffer_size(out);
|
||||
zs.next_out = out.data();
|
||||
zs.avail_out = out.size();
|
||||
BOOST_ASSERT(zs.avail_out > 0);
|
||||
}
|
||||
if(ws_.rd_remain_ > 0)
|
||||
@@ -501,8 +494,8 @@ operator()(
|
||||
auto const in = buffers_prefix(
|
||||
clamp(ws_.rd_remain_), buffers_front(
|
||||
ws_.rd_buf_.data()));
|
||||
zs.avail_in = buffer_size(in);
|
||||
zs.next_in = buffer_cast<void const*>(in);
|
||||
zs.avail_in = in.size();
|
||||
zs.next_in = in.data();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -594,7 +587,8 @@ operator()(
|
||||
|
||||
// Resume
|
||||
BOOST_ASIO_CORO_YIELD
|
||||
ws_.get_io_service().post(std::move(*this));
|
||||
boost::asio::post(
|
||||
ws_.get_executor(), std::move(*this));
|
||||
BOOST_ASSERT(ws_.wr_block_ == tok_);
|
||||
|
||||
// Make sure the stream is open
|
||||
@@ -659,7 +653,8 @@ operator()(
|
||||
ws_.paused_wr_.maybe_invoke();
|
||||
}
|
||||
if(! cont_)
|
||||
return ws_.stream_.get_io_service().post(
|
||||
return boost::asio::post(
|
||||
ws_.stream_.get_executor(),
|
||||
bind_handler(std::move(h_),
|
||||
ec, bytes_written_));
|
||||
h_(ec, bytes_written_);
|
||||
@@ -683,6 +678,9 @@ class stream<NextLayer>::read_op
|
||||
bool some_;
|
||||
|
||||
public:
|
||||
using allocator_type =
|
||||
boost::asio::associated_allocator_t<Handler>;
|
||||
|
||||
read_op(read_op&&) = default;
|
||||
read_op(read_op const&) = default;
|
||||
|
||||
@@ -702,28 +700,25 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_allocator(h_);
|
||||
}
|
||||
|
||||
using executor_type = boost::asio::associated_executor_t<
|
||||
Handler, decltype(ws_.get_executor())>;
|
||||
|
||||
executor_type get_executor() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_executor(
|
||||
h_, ws_.get_executor());
|
||||
}
|
||||
|
||||
void operator()(
|
||||
error_code ec = {},
|
||||
std::size_t bytes_transferred = 0);
|
||||
|
||||
friend
|
||||
void* asio_handler_allocate(
|
||||
std::size_t size, read_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_allocate;
|
||||
return asio_handler_allocate(
|
||||
size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
void asio_handler_deallocate(
|
||||
void* p, std::size_t size, read_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_deallocate;
|
||||
asio_handler_deallocate(
|
||||
p, size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
bool asio_handler_is_continuation(read_op* op)
|
||||
{
|
||||
@@ -731,15 +726,6 @@ public:
|
||||
return asio_handler_is_continuation(
|
||||
std::addressof(op->h_));
|
||||
}
|
||||
|
||||
template<class Function>
|
||||
friend
|
||||
void asio_handler_invoke(Function&& f, read_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_invoke;
|
||||
asio_handler_invoke(
|
||||
f, std::addressof(op->h_));
|
||||
}
|
||||
};
|
||||
|
||||
template<class NextLayer>
|
||||
@@ -771,7 +757,8 @@ operator()(
|
||||
if(ec)
|
||||
{
|
||||
BOOST_ASIO_CORO_YIELD
|
||||
ws_.get_io_service().post(
|
||||
boost::asio::post(
|
||||
ws_.get_executor(),
|
||||
bind_handler(std::move(*this),
|
||||
error::buffer_overflow, 0));
|
||||
break;
|
||||
@@ -800,7 +787,8 @@ read(DynamicBuffer& buffer)
|
||||
{
|
||||
static_assert(is_sync_stream<next_layer_type>::value,
|
||||
"SyncStream requirements not met");
|
||||
static_assert(beast::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
static_assert(
|
||||
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
"DynamicBuffer requirements not met");
|
||||
error_code ec;
|
||||
auto const bytes_written = read(buffer, ec);
|
||||
@@ -817,7 +805,8 @@ read(DynamicBuffer& buffer, error_code& ec)
|
||||
{
|
||||
static_assert(is_sync_stream<next_layer_type>::value,
|
||||
"SyncStream requirements not met");
|
||||
static_assert(beast::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
static_assert(
|
||||
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
"DynamicBuffer requirements not met");
|
||||
std::size_t bytes_written = 0;
|
||||
do
|
||||
@@ -832,24 +821,27 @@ read(DynamicBuffer& buffer, error_code& ec)
|
||||
|
||||
template<class NextLayer>
|
||||
template<class DynamicBuffer, class ReadHandler>
|
||||
async_return_type<ReadHandler, void(error_code, std::size_t)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
ReadHandler, void(error_code, std::size_t))
|
||||
stream<NextLayer>::
|
||||
async_read(DynamicBuffer& buffer, ReadHandler&& handler)
|
||||
{
|
||||
static_assert(is_async_stream<next_layer_type>::value,
|
||||
"AsyncStream requirements requirements not met");
|
||||
static_assert(beast::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
static_assert(
|
||||
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
"DynamicBuffer requirements not met");
|
||||
async_completion<
|
||||
boost::asio::async_completion<
|
||||
ReadHandler, void(error_code, std::size_t)> init{handler};
|
||||
read_op<
|
||||
DynamicBuffer,
|
||||
handler_type<ReadHandler, void(error_code, std::size_t)> >{
|
||||
init.completion_handler,
|
||||
*this,
|
||||
buffer,
|
||||
0,
|
||||
false}();
|
||||
BOOST_ASIO_HANDLER_TYPE(
|
||||
ReadHandler, void(error_code, std::size_t))>{
|
||||
init.completion_handler,
|
||||
*this,
|
||||
buffer,
|
||||
0,
|
||||
false}();
|
||||
return init.result.get();
|
||||
}
|
||||
|
||||
@@ -865,7 +857,8 @@ read_some(
|
||||
{
|
||||
static_assert(is_sync_stream<next_layer_type>::value,
|
||||
"SyncStream requirements not met");
|
||||
static_assert(beast::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
static_assert(
|
||||
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
"DynamicBuffer requirements not met");
|
||||
error_code ec;
|
||||
auto const bytes_written =
|
||||
@@ -886,7 +879,8 @@ read_some(
|
||||
{
|
||||
static_assert(is_sync_stream<next_layer_type>::value,
|
||||
"SyncStream requirements not met");
|
||||
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
|
||||
static_assert(
|
||||
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
"DynamicBuffer requirements not met");
|
||||
using beast::detail::clamp;
|
||||
if(! limit)
|
||||
@@ -912,8 +906,8 @@ read_some(
|
||||
|
||||
template<class NextLayer>
|
||||
template<class DynamicBuffer, class ReadHandler>
|
||||
async_return_type<ReadHandler,
|
||||
void(error_code, std::size_t)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
ReadHandler, void(error_code, std::size_t))
|
||||
stream<NextLayer>::
|
||||
async_read_some(
|
||||
DynamicBuffer& buffer,
|
||||
@@ -922,19 +916,20 @@ async_read_some(
|
||||
{
|
||||
static_assert(is_async_stream<next_layer_type>::value,
|
||||
"AsyncStream requirements requirements not met");
|
||||
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
|
||||
static_assert(
|
||||
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
"DynamicBuffer requirements not met");
|
||||
async_completion<ReadHandler,
|
||||
boost::asio::async_completion<ReadHandler,
|
||||
void(error_code, std::size_t)> init{handler};
|
||||
read_op<
|
||||
DynamicBuffer,
|
||||
handler_type<ReadHandler,
|
||||
void(error_code, std::size_t)>>{
|
||||
init.completion_handler,
|
||||
*this,
|
||||
buffer,
|
||||
limit,
|
||||
true}({}, 0);
|
||||
BOOST_ASIO_HANDLER_TYPE(
|
||||
ReadHandler, void(error_code, std::size_t))>{
|
||||
init.completion_handler,
|
||||
*this,
|
||||
buffer,
|
||||
limit,
|
||||
true}({}, 0);
|
||||
return init.result.get();
|
||||
}
|
||||
|
||||
@@ -949,7 +944,7 @@ read_some(
|
||||
{
|
||||
static_assert(is_sync_stream<next_layer_type>::value,
|
||||
"SyncStream requirements not met");
|
||||
static_assert(is_mutable_buffer_sequence<
|
||||
static_assert(boost::asio::is_mutable_buffer_sequence<
|
||||
MutableBufferSequence>::value,
|
||||
"MutableBufferSequence requirements not met");
|
||||
error_code ec;
|
||||
@@ -969,12 +964,11 @@ read_some(
|
||||
{
|
||||
static_assert(is_sync_stream<next_layer_type>::value,
|
||||
"SyncStream requirements not met");
|
||||
static_assert(is_mutable_buffer_sequence<
|
||||
static_assert(boost::asio::is_mutable_buffer_sequence<
|
||||
MutableBufferSequence>::value,
|
||||
"MutableBufferSequence requirements not met");
|
||||
using beast::detail::clamp;
|
||||
using boost::asio::buffer;
|
||||
using boost::asio::buffer_cast;
|
||||
using boost::asio::buffer_size;
|
||||
close_code code{};
|
||||
std::size_t bytes_written = 0;
|
||||
@@ -1191,8 +1185,8 @@ loop:
|
||||
zlib::z_params zs;
|
||||
{
|
||||
auto const out = buffers_front(cb);
|
||||
zs.next_out = buffer_cast<void*>(out);
|
||||
zs.avail_out = buffer_size(out);
|
||||
zs.next_out = out.data();
|
||||
zs.avail_out = out.size();
|
||||
BOOST_ASSERT(zs.avail_out > 0);
|
||||
}
|
||||
if(rd_remain_ > 0)
|
||||
@@ -1203,8 +1197,8 @@ loop:
|
||||
auto const in = buffers_prefix(
|
||||
clamp(rd_remain_), buffers_front(
|
||||
rd_buf_.data()));
|
||||
zs.avail_in = buffer_size(in);
|
||||
zs.next_in = buffer_cast<void const*>(in);
|
||||
zs.avail_in = in.size();
|
||||
zs.next_in = in.data();
|
||||
}
|
||||
else if(! did_read)
|
||||
{
|
||||
@@ -1225,8 +1219,8 @@ loop:
|
||||
auto const in = buffers_prefix(
|
||||
clamp(rd_remain_), buffers_front(
|
||||
rd_buf_.data()));
|
||||
zs.avail_in = buffer_size(in);
|
||||
zs.next_in = buffer_cast<void const*>(in);
|
||||
zs.avail_in = in.size();
|
||||
zs.next_in = in.data();
|
||||
did_read = true;
|
||||
}
|
||||
else
|
||||
@@ -1299,7 +1293,8 @@ loop:
|
||||
|
||||
template<class NextLayer>
|
||||
template<class MutableBufferSequence, class ReadHandler>
|
||||
async_return_type<ReadHandler, void(error_code, std::size_t)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
ReadHandler, void(error_code, std::size_t))
|
||||
stream<NextLayer>::
|
||||
async_read_some(
|
||||
MutableBufferSequence const& buffers,
|
||||
@@ -1307,13 +1302,13 @@ async_read_some(
|
||||
{
|
||||
static_assert(is_async_stream<next_layer_type>::value,
|
||||
"AsyncStream requirements requirements not met");
|
||||
static_assert(is_mutable_buffer_sequence<
|
||||
static_assert(boost::asio::is_mutable_buffer_sequence<
|
||||
MutableBufferSequence>::value,
|
||||
"MutableBufferSequence requirements not met");
|
||||
async_completion<ReadHandler,
|
||||
boost::asio::async_completion<ReadHandler,
|
||||
void(error_code, std::size_t)> init{handler};
|
||||
read_some_op<MutableBufferSequence, handler_type<
|
||||
ReadHandler, void(error_code, std::size_t)>>{
|
||||
read_some_op<MutableBufferSequence, BOOST_ASIO_HANDLER_TYPE(
|
||||
ReadHandler, void(error_code, std::size_t))>{
|
||||
init.completion_handler,*this, buffers}(
|
||||
{}, 0, false);
|
||||
return init.result.get();
|
||||
|
||||
@@ -91,7 +91,8 @@ std::size_t
|
||||
stream<NextLayer>::
|
||||
read_size_hint(DynamicBuffer& buffer) const
|
||||
{
|
||||
static_assert(is_dynamic_buffer<DynamicBuffer>::value,
|
||||
static_assert(
|
||||
boost::asio::is_dynamic_buffer<DynamicBuffer>::value,
|
||||
"DynamicBuffer requirements not met");
|
||||
auto const initial_size = (std::min)(
|
||||
+tcp_frame_size,
|
||||
@@ -503,7 +504,7 @@ write_ping(DynamicBuffer& db,
|
||||
detail::prepare_key(key, fh.key);
|
||||
auto mb = db.prepare(data.size());
|
||||
boost::asio::buffer_copy(mb,
|
||||
boost::asio::const_buffers_1(
|
||||
boost::asio::const_buffer(
|
||||
data.data(), data.size()));
|
||||
if(fh.mask)
|
||||
detail::mask_inplace(mb, key);
|
||||
|
||||
@@ -12,9 +12,10 @@
|
||||
|
||||
#include <boost/beast/core/bind_handler.hpp>
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/associated_allocator.hpp>
|
||||
#include <boost/asio/associated_executor.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/asio/post.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace boost {
|
||||
@@ -49,29 +50,29 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
using allocator_type =
|
||||
boost::asio::associated_allocator_t<Handler>;
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_allocator(h_);
|
||||
}
|
||||
|
||||
using executor_type = boost::asio::associated_executor_t<
|
||||
Handler, decltype(s_.get_executor())>;
|
||||
|
||||
executor_type get_executor() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_executor(
|
||||
h_, s_.get_executor());
|
||||
}
|
||||
|
||||
void
|
||||
operator()(
|
||||
error_code ec = {},
|
||||
std::size_t bytes_transferred = 0);
|
||||
|
||||
friend
|
||||
void* asio_handler_allocate(std::size_t size,
|
||||
teardown_tcp_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_allocate;
|
||||
return asio_handler_allocate(
|
||||
size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
void asio_handler_deallocate(void* p,
|
||||
std::size_t size, teardown_tcp_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_deallocate;
|
||||
asio_handler_deallocate(
|
||||
p, size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
bool asio_handler_is_continuation(teardown_tcp_op* op)
|
||||
{
|
||||
@@ -79,16 +80,6 @@ public:
|
||||
return op->step_ >= 3 ||
|
||||
asio_handler_is_continuation(std::addressof(op->h_));
|
||||
}
|
||||
|
||||
template<class Function>
|
||||
friend
|
||||
void asio_handler_invoke(Function&& f,
|
||||
teardown_tcp_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_invoke;
|
||||
asio_handler_invoke(
|
||||
f, std::addressof(op->h_));
|
||||
}
|
||||
};
|
||||
|
||||
template<class Handler>
|
||||
@@ -105,7 +96,8 @@ operator()(error_code ec, std::size_t)
|
||||
if(ec)
|
||||
{
|
||||
step_ = 1;
|
||||
return s_.get_io_service().post(
|
||||
return boost::asio::post(
|
||||
s_.get_executor(),
|
||||
bind_handler(std::move(*this), ec, 0));
|
||||
}
|
||||
step_ = 2;
|
||||
|
||||
@@ -20,10 +20,10 @@
|
||||
#include <boost/beast/core/detail/clamp.hpp>
|
||||
#include <boost/beast/core/detail/config.hpp>
|
||||
#include <boost/beast/websocket/detail/frame.hpp>
|
||||
#include <boost/asio/associated_allocator.hpp>
|
||||
#include <boost/asio/associated_executor.hpp>
|
||||
#include <boost/asio/coroutine.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/config.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
@@ -71,6 +71,24 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
using allocator_type =
|
||||
boost::asio::associated_allocator_t<Handler>;
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_allocator(h_);
|
||||
}
|
||||
|
||||
using executor_type = boost::asio::associated_executor_t<
|
||||
Handler, decltype(ws_.get_executor())>;
|
||||
|
||||
executor_type get_executor() const noexcept
|
||||
{
|
||||
return boost::asio::get_associated_executor(
|
||||
h_, ws_.get_executor());
|
||||
}
|
||||
|
||||
Handler&
|
||||
handler()
|
||||
{
|
||||
@@ -82,24 +100,6 @@ public:
|
||||
std::size_t bytes_transferred = 0,
|
||||
bool cont = true);
|
||||
|
||||
friend
|
||||
void* asio_handler_allocate(
|
||||
std::size_t size, write_some_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_allocate;
|
||||
return asio_handler_allocate(
|
||||
size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
void asio_handler_deallocate(
|
||||
void* p, std::size_t size, write_some_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_deallocate;
|
||||
asio_handler_deallocate(
|
||||
p, size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
bool asio_handler_is_continuation(write_some_op* op)
|
||||
{
|
||||
@@ -107,15 +107,6 @@ public:
|
||||
return op->cont_ || asio_handler_is_continuation(
|
||||
std::addressof(op->h_));
|
||||
}
|
||||
|
||||
template<class Function>
|
||||
friend
|
||||
void asio_handler_invoke(Function&& f, write_some_op* op)
|
||||
{
|
||||
using boost::asio::asio_handler_invoke;
|
||||
asio_handler_invoke(
|
||||
f, std::addressof(op->h_));
|
||||
}
|
||||
};
|
||||
|
||||
template<class NextLayer>
|
||||
@@ -132,7 +123,7 @@ operator()(
|
||||
using boost::asio::buffer;
|
||||
using boost::asio::buffer_copy;
|
||||
using boost::asio::buffer_size;
|
||||
using boost::asio::mutable_buffers_1;
|
||||
using boost::asio::mutable_buffer;
|
||||
enum
|
||||
{
|
||||
do_nomask_nofrag,
|
||||
@@ -225,7 +216,8 @@ operator()(
|
||||
|
||||
// Resume
|
||||
BOOST_ASIO_CORO_YIELD
|
||||
ws_.get_io_service().post(std::move(*this));
|
||||
boost::asio::post(
|
||||
ws_.get_executor(), std::move(*this));
|
||||
BOOST_ASSERT(ws_.wr_block_ == tok_);
|
||||
|
||||
// Make sure the stream is open
|
||||
@@ -435,8 +427,8 @@ operator()(
|
||||
// Send frame
|
||||
BOOST_ASIO_CORO_YIELD
|
||||
boost::asio::async_write(ws_.stream_,
|
||||
buffers_cat(ws_.wr_fb_.data(),
|
||||
mutable_buffers_1{b}), std::move(*this));
|
||||
buffers_cat(ws_.wr_fb_.data(), b),
|
||||
std::move(*this));
|
||||
if(! ws_.check_ok(ec))
|
||||
goto upcall;
|
||||
bytes_transferred_ += in_;
|
||||
@@ -478,7 +470,8 @@ operator()(
|
||||
ws_.paused_rd_.maybe_invoke() ||
|
||||
ws_.paused_ping_.maybe_invoke();
|
||||
if(! cont_)
|
||||
return ws_.stream_.get_io_service().post(
|
||||
return boost::asio::post(
|
||||
ws_.stream_.get_executor(),
|
||||
bind_handler(h_, ec, bytes_transferred_));
|
||||
h_(ec, bytes_transferred_);
|
||||
}
|
||||
@@ -494,7 +487,7 @@ write_some(bool fin, ConstBufferSequence const& buffers)
|
||||
{
|
||||
static_assert(is_sync_stream<next_layer_type>::value,
|
||||
"SyncStream requirements not met");
|
||||
static_assert(beast::is_const_buffer_sequence<
|
||||
static_assert(boost::asio::is_const_buffer_sequence<
|
||||
ConstBufferSequence>::value,
|
||||
"ConstBufferSequence requirements not met");
|
||||
error_code ec;
|
||||
@@ -514,7 +507,7 @@ write_some(bool fin,
|
||||
{
|
||||
static_assert(is_sync_stream<next_layer_type>::value,
|
||||
"SyncStream requirements not met");
|
||||
static_assert(beast::is_const_buffer_sequence<
|
||||
static_assert(boost::asio::is_const_buffer_sequence<
|
||||
ConstBufferSequence>::value,
|
||||
"ConstBufferSequence requirements not met");
|
||||
using beast::detail::clamp;
|
||||
@@ -720,21 +713,21 @@ write_some(bool fin,
|
||||
|
||||
template<class NextLayer>
|
||||
template<class ConstBufferSequence, class WriteHandler>
|
||||
async_return_type<
|
||||
WriteHandler, void(error_code, std::size_t)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
WriteHandler, void(error_code, std::size_t))
|
||||
stream<NextLayer>::
|
||||
async_write_some(bool fin,
|
||||
ConstBufferSequence const& bs, WriteHandler&& handler)
|
||||
{
|
||||
static_assert(is_async_stream<next_layer_type>::value,
|
||||
"AsyncStream requirements not met");
|
||||
static_assert(beast::is_const_buffer_sequence<
|
||||
static_assert(boost::asio::is_const_buffer_sequence<
|
||||
ConstBufferSequence>::value,
|
||||
"ConstBufferSequence requirements not met");
|
||||
async_completion<WriteHandler,
|
||||
boost::asio::async_completion<WriteHandler,
|
||||
void(error_code, std::size_t)> init{handler};
|
||||
write_some_op<ConstBufferSequence, handler_type<
|
||||
WriteHandler, void(error_code, std::size_t)>>{
|
||||
write_some_op<ConstBufferSequence, BOOST_ASIO_HANDLER_TYPE(
|
||||
WriteHandler, void(error_code, std::size_t))>{
|
||||
init.completion_handler, *this, fin, bs}(
|
||||
{}, 0, false);
|
||||
return init.result.get();
|
||||
@@ -750,7 +743,7 @@ write(ConstBufferSequence const& buffers)
|
||||
{
|
||||
static_assert(is_sync_stream<next_layer_type>::value,
|
||||
"SyncStream requirements not met");
|
||||
static_assert(beast::is_const_buffer_sequence<
|
||||
static_assert(boost::asio::is_const_buffer_sequence<
|
||||
ConstBufferSequence>::value,
|
||||
"ConstBufferSequence requirements not met");
|
||||
error_code ec;
|
||||
@@ -768,7 +761,7 @@ write(ConstBufferSequence const& buffers, error_code& ec)
|
||||
{
|
||||
static_assert(is_sync_stream<next_layer_type>::value,
|
||||
"SyncStream requirements not met");
|
||||
static_assert(beast::is_const_buffer_sequence<
|
||||
static_assert(boost::asio::is_const_buffer_sequence<
|
||||
ConstBufferSequence>::value,
|
||||
"ConstBufferSequence requirements not met");
|
||||
return write_some(true, buffers, ec);
|
||||
@@ -776,21 +769,21 @@ write(ConstBufferSequence const& buffers, error_code& ec)
|
||||
|
||||
template<class NextLayer>
|
||||
template<class ConstBufferSequence, class WriteHandler>
|
||||
async_return_type<
|
||||
WriteHandler, void(error_code, std::size_t)>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||
WriteHandler, void(error_code, std::size_t))
|
||||
stream<NextLayer>::
|
||||
async_write(
|
||||
ConstBufferSequence const& bs, WriteHandler&& handler)
|
||||
{
|
||||
static_assert(is_async_stream<next_layer_type>::value,
|
||||
"AsyncStream requirements not met");
|
||||
static_assert(beast::is_const_buffer_sequence<
|
||||
static_assert(boost::asio::is_const_buffer_sequence<
|
||||
ConstBufferSequence>::value,
|
||||
"ConstBufferSequence requirements not met");
|
||||
async_completion<WriteHandler,
|
||||
boost::asio::async_completion<WriteHandler,
|
||||
void(error_code, std::size_t)> init{handler};
|
||||
write_some_op<ConstBufferSequence, handler_type<
|
||||
WriteHandler, void(error_code, std::size_t)>>{
|
||||
write_some_op<ConstBufferSequence, BOOST_ASIO_HANDLER_TYPE(
|
||||
WriteHandler, void(error_code, std::size_t))>{
|
||||
init.completion_handler, *this, true, bs}(
|
||||
{}, 0, false);
|
||||
return init.result.get();
|
||||
|
||||
Reference in new issue
Block a user