Add executor_type trait

This commit is contained in:
Vinnie Falco
2019-02-04 21:52:54 -08:00
parent 42d83b221a
commit 9cee4e053f
21 changed files with 97 additions and 98 deletions
@@ -10,9 +10,9 @@
#ifndef BOOST_BEAST_CORE_IMPL_FLAT_STREAM_HPP
#define BOOST_BEAST_CORE_IMPL_FLAT_STREAM_HPP
#include <boost/beast/core/buffers_prefix.hpp>
#include <boost/beast/core/async_op_base.hpp>
#include <boost/beast/core/detail/get_executor_type.hpp>
#include <boost/beast/core/buffers_prefix.hpp>
#include <boost/beast/core/stream_traits.hpp>
#include <boost/beast/websocket/teardown.hpp>
#include <boost/asio/buffer.hpp>
#include <boost/asio/coroutine.hpp>
@@ -25,7 +25,7 @@ template<class NextLayer>
template<class ConstBufferSequence, class Handler>
class flat_stream<NextLayer>::write_op
: public async_op_base<Handler,
detail::get_executor_type<flat_stream>>
beast::executor_type<flat_stream>>
, public net::coroutine
{
@@ -60,7 +60,7 @@ public:
ConstBufferSequence const& b,
Handler_&& h)
: async_op_base<Handler,
detail::get_executor_type<flat_stream>>(
beast::executor_type<flat_stream>>(
std::forward<Handler_>(h),
s.get_executor())
, s_(s)
@@ -10,15 +10,15 @@
#ifndef BOOST_BEAST_CORE_IMPL_ICY_STREAM_HPP
#define BOOST_BEAST_CORE_IMPL_ICY_STREAM_HPP
#include <boost/beast/core/dynamic_buffer_ref.hpp>
#include <boost/beast/core/async_op_base.hpp>
#include <boost/beast/core/bind_handler.hpp>
#include <boost/beast/core/buffer_size.hpp>
#include <boost/beast/core/buffers_adaptor.hpp>
#include <boost/beast/core/buffers_prefix.hpp>
#include <boost/beast/core/buffers_suffix.hpp>
#include <boost/beast/core/dynamic_buffer_ref.hpp>
#include <boost/beast/core/stream_traits.hpp>
#include <boost/beast/core/detail/buffers_ref.hpp>
#include <boost/beast/core/detail/get_executor_type.hpp>
#include <boost/asio/buffers_iterator.hpp>
#include <boost/asio/coroutine.hpp>
#include <boost/asio/post.hpp>
@@ -121,7 +121,7 @@ template<class NextLayer>
template<class MutableBufferSequence, class Handler>
class icy_stream<NextLayer>::read_op
: public beast::stable_async_op_base<Handler,
beast::detail::get_executor_type<icy_stream>>
beast::executor_type<icy_stream>>
, public net::coroutine
{
// VFALCO We need a stable reference to `b`
@@ -151,7 +151,7 @@ public:
icy_stream& s,
MutableBufferSequence const& b)
: stable_async_op_base<Handler,
beast::detail::get_executor_type<icy_stream>>(
beast::executor_type<icy_stream>>(
std::forward<Handler_>(h), s.get_executor())
, d_(beast::allocate_stable<data>(*this, s, b))
{
@@ -13,8 +13,8 @@
#include <boost/beast/core/detail/config.hpp>
#include <boost/beast/core/error.hpp>
#include <boost/beast/core/multi_buffer.hpp>
#include <boost/beast/core/stream_traits.hpp>
#include <boost/beast/core/type_traits.hpp>
#include <boost/beast/core/detail/get_executor_type.hpp>
#include <boost/asio/async_result.hpp>
#include <boost/asio/buffer.hpp>
#include <boost/asio/io_context.hpp>
@@ -148,7 +148,7 @@ public:
}
using executor_type =
detail::get_executor_type<next_layer_type>;
beast::executor_type<next_layer_type>;
/** Get the executor associated with the object.
@@ -1,35 +0,0 @@
//
// Copyright (c) 2016-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)
//
// Official repository: https://github.com/boostorg/beast
//
#ifndef BOOST_BEAST_DETAIL_GET_EXECUTOR_TYPE
#define BOOST_BEAST_DETAIL_GET_EXECUTOR_TYPE
#include <boost/config/workaround.hpp>
#include <utility>
namespace boost {
namespace beast {
namespace detail {
// Workaround for ICE on gcc 4.8
#if BOOST_WORKAROUND(BOOST_GCC, < 40900)
template<class T>
using get_executor_type =
typename std::decay<T>::type::executor_type;
#else
template<class T>
using get_executor_type =
decltype(std::declval<T&>().get_executor());
#endif
} // detail
} // beast
} // boost
#endif
@@ -13,7 +13,7 @@
#include <boost/beast/core/bind_handler.hpp>
#include <boost/beast/core/async_op_base.hpp>
#include <boost/beast/core/flat_static_buffer.hpp>
#include <boost/beast/core/detail/get_executor_type.hpp>
#include <boost/beast/core/stream_traits.hpp>
#include <boost/asio/basic_stream_socket.hpp>
#include <boost/asio/coroutine.hpp>
#include <boost/throw_exception.hpp>
@@ -37,7 +37,7 @@ template<
class read_op
: public net::coroutine
, public async_op_base<
Handler, get_executor_type<Stream>>
Handler, beast::executor_type<Stream>>
{
Stream& s_;
DynamicBuffer& b_;
@@ -54,7 +54,7 @@ public:
Condition cond,
Handler_&& h)
: async_op_base<Handler,
get_executor_type<Stream>>(
beast::executor_type<Stream>>(
std::forward<Handler_>(h),
s.get_executor())
, s_(s)
@@ -115,7 +115,7 @@ template<
class read_non_blocking_op
: public net::coroutine
, public async_op_base<Handler,
get_executor_type<net::basic_stream_socket<Protocol>>>
beast::executor_type<net::basic_stream_socket<Protocol>>>
{
net::basic_stream_socket<Protocol>& s_;
DynamicBuffer& b_;
@@ -133,7 +133,7 @@ public:
DynamicBuffer& b,
Condition cond,
Handler_&& h)
: async_op_base<Handler, get_executor_type<
: async_op_base<Handler, beast::executor_type<
net::basic_stream_socket<Protocol>>>(
s.get_executor(), std::forward<Handler_>(h))
, s_(s)
@@ -14,8 +14,8 @@
#include <boost/beast/core/bind_handler.hpp>
#include <boost/beast/core/error.hpp>
#include <boost/beast/core/read_size.hpp>
#include <boost/beast/core/stream_traits.hpp>
#include <boost/beast/core/type_traits.hpp>
#include <boost/beast/core/detail/get_executor_type.hpp>
#include <boost/asio/post.hpp>
#include <boost/throw_exception.hpp>
@@ -27,7 +27,7 @@ template<class MutableBufferSequence, class Handler>
class buffered_read_stream<
Stream, DynamicBuffer>::read_some_op
: public async_op_base<
Handler, detail::get_executor_type<buffered_read_stream>>
Handler, beast::executor_type<buffered_read_stream>>
{
buffered_read_stream& s_;
MutableBufferSequence b_;
@@ -43,7 +43,7 @@ public:
buffered_read_stream& s,
MutableBufferSequence const& b)
: async_op_base<
Handler, detail::get_executor_type<buffered_read_stream>>(
Handler, beast::executor_type<buffered_read_stream>>(
std::forward<Handler_>(h), s.get_executor())
, s_(s)
, b_(b)
+31 -5
View File
@@ -16,12 +16,15 @@
namespace boost {
namespace beast {
/** Return the type of the lowest layer of a type representing a stack of stream layers.
/** A trait to determine the lowest layer type of a stack of stream layers.
This type alias will return the type of lowest layer object for a type
which defines a stack of stream layers.
If `t.next_layer()` is well-defined for an object `t` of type `T`,
then `lowest_layer_type<T>` will be an alias for
`lowest_layer_type<decltype(t.next_layer())>`,
otherwise it will be the type
`std::remove_reference<T>`.
@param T The type determine the lowest layer type of.
@param T The type to determine the lowest layer type of.
@return The type of the lowest layer.
*/
@@ -35,7 +38,7 @@ using lowest_layer_type = detail::lowest_layer_type<T>;
/** Return the lowest layer in a stack of stream layers.
If `t.next_layer()` is well-defined, returns
`lowest_layer(t.next_layer())`. Otherwise, it returns `t`.
`get_lowest_layer(t.next_layer())`. Otherwise, it returns `t`.
A stream layer is an object of class type which wraps another object through
composition, and meets some or all of the named requirements of the wrapped
@@ -84,6 +87,29 @@ get_lowest_layer(T& t) noexcept
t, detail::has_next_layer<T>{});
}
/** A trait to determine the return type of get_executor.
This type alias will be the type of values returned by
by calling member `get_exector` on an object of type `T&`.
@param T The type to query
@return The type of values returned from `get_executor`.
*/
// Workaround for ICE on gcc 4.8
#if BOOST_BEAST_DOXYGEN
template<class T>
using executor_type = __see_below__;
#elif BOOST_WORKAROUND(BOOST_GCC, < 40900)
template<class T>
using executor_type =
typename std::decay<T>::type::executor_type;
#else
template<class T>
using executor_type =
decltype(std::declval<T&>().get_executor());
#endif
} // beast
} // boost
+3 -3
View File
@@ -15,7 +15,7 @@
#include <boost/beast/http/parser.hpp>
#include <boost/beast/http/read.hpp>
#include <boost/beast/core/async_op_base.hpp>
#include <boost/beast/core/detail/get_executor_type.hpp>
#include <boost/beast/core/stream_traits.hpp>
#include <boost/beast/core/detail/read.hpp>
#include <boost/asio/error.hpp>
@@ -149,7 +149,7 @@ template<
class Handler>
class read_msg_op
: public beast::stable_async_op_base<
Handler, beast::detail::get_executor_type<Stream>>
Handler, beast::executor_type<Stream>>
, public net::coroutine
{
using parser_type =
@@ -184,7 +184,7 @@ public:
message_type& m,
Handler_&& h)
: stable_async_op_base<
Handler, beast::detail::get_executor_type<Stream>>(
Handler, beast::executor_type<Stream>>(
std::forward<Handler_>(h), s.get_executor())
, d_(beast::allocate_stable<data>(
*this, s, m))
+7 -7
View File
@@ -15,8 +15,8 @@
#include <boost/beast/core/bind_handler.hpp>
#include <boost/beast/core/buffers_range.hpp>
#include <boost/beast/core/ostream.hpp>
#include <boost/beast/core/stream_traits.hpp>
#include <boost/beast/core/type_traits.hpp>
#include <boost/beast/core/detail/get_executor_type.hpp>
#include <boost/asio/coroutine.hpp>
#include <boost/asio/post.hpp>
#include <boost/asio/write.hpp>
@@ -35,7 +35,7 @@ template<
bool isRequest, class Body, class Fields>
class write_some_op
: public beast::async_op_base<
Handler, beast::detail::get_executor_type<Stream>>
Handler, beast::executor_type<Stream>>
{
Stream& s_;
serializer<isRequest,Body, Fields>& sr_;
@@ -73,7 +73,7 @@ public:
Stream& s,
serializer<isRequest, Body, Fields>& sr)
: async_op_base<
Handler, beast::detail::get_executor_type<Stream>>(
Handler, beast::executor_type<Stream>>(
std::forward<Handler_>(h), s.get_executor())
, s_(s)
, sr_(sr)
@@ -155,7 +155,7 @@ template<
bool isRequest, class Body, class Fields>
class write_op
: public beast::async_op_base<
Handler, beast::detail::get_executor_type<Stream>>
Handler, beast::executor_type<Stream>>
, public net::coroutine
{
Stream& s_;
@@ -169,7 +169,7 @@ public:
Stream& s,
serializer<isRequest, Body, Fields>& sr)
: async_op_base<
Handler, beast::detail::get_executor_type<Stream>>(
Handler, beast::executor_type<Stream>>(
std::forward<Handler_>(h), s.get_executor())
, s_(s)
, sr_(sr)
@@ -216,7 +216,7 @@ template<
bool isRequest, class Body, class Fields>
class write_msg_op
: public beast::stable_async_op_base<
Handler, beast::detail::get_executor_type<Stream>>
Handler, beast::executor_type<Stream>>
{
Stream& s_;
serializer<isRequest, Body, Fields>& sr_;
@@ -230,7 +230,7 @@ public:
Handler_&& h,
Args&&... args)
: stable_async_op_base<
Handler, beast::detail::get_executor_type<Stream>>(
Handler, beast::executor_type<Stream>>(
std::forward<Handler_>(h), s.get_executor())
, s_(s)
, sr_(beast::allocate_stable<
@@ -19,8 +19,8 @@
#include <boost/beast/http/write.hpp>
#include <boost/beast/core/async_op_base.hpp>
#include <boost/beast/core/buffers_prefix.hpp>
#include <boost/beast/core/stream_traits.hpp>
#include <boost/beast/core/detail/buffer.hpp>
#include <boost/beast/core/detail/get_executor_type.hpp>
#include <boost/beast/core/detail/type_traits.hpp>
#include <boost/asio/coroutine.hpp>
#include <boost/asio/post.hpp>
@@ -39,7 +39,7 @@ template<class NextLayer, bool deflateSupported>
template<class Handler>
class stream<NextLayer, deflateSupported>::response_op
: public beast::stable_async_op_base<
Handler, beast::detail::get_executor_type<stream>>
Handler, beast::executor_type<stream>>
, public net::coroutine
{
stream<NextLayer, deflateSupported>& ws_;
@@ -57,7 +57,7 @@ public:
http::request<Body, http::basic_fields<Allocator>> const& req,
Decorator const& decorator)
: stable_async_op_base<
Handler, beast::detail::get_executor_type<stream>>(
Handler, beast::executor_type<stream>>(
std::forward<Handler_>(h), ws.get_executor())
, ws_(ws)
, res_(beast::allocate_stable<response_type>(*this,
@@ -96,7 +96,7 @@ template<class NextLayer, bool deflateSupported>
template<class Decorator, class Handler>
class stream<NextLayer, deflateSupported>::accept_op
: public beast::stable_async_op_base<
Handler, beast::detail::get_executor_type<stream>>
Handler, beast::executor_type<stream>>
, public net::coroutine
{
stream<NextLayer, deflateSupported>& ws_;
@@ -110,7 +110,7 @@ public:
stream<NextLayer, deflateSupported>& ws,
Decorator const& decorator)
: stable_async_op_base<
Handler, beast::detail::get_executor_type<stream>>(
Handler, beast::executor_type<stream>>(
std::forward<Handler_>(h), ws.get_executor())
, ws_(ws)
, p_(beast::allocate_stable<
+3 -3
View File
@@ -14,8 +14,8 @@
#include <boost/beast/websocket/detail/mask.hpp>
#include <boost/beast/core/async_op_base.hpp>
#include <boost/beast/core/flat_static_buffer.hpp>
#include <boost/beast/core/stream_traits.hpp>
#include <boost/beast/core/type_traits.hpp>
#include <boost/beast/core/detail/get_executor_type.hpp>
#include <boost/beast/core/detail/config.hpp>
#include <boost/asio/coroutine.hpp>
#include <boost/asio/post.hpp>
@@ -37,7 +37,7 @@ template<class NextLayer, bool deflateSupported>
template<class Handler>
class stream<NextLayer, deflateSupported>::close_op
: public beast::stable_async_op_base<
Handler, beast::detail::get_executor_type<stream>>
Handler, beast::executor_type<stream>>
, public net::coroutine
{
struct state
@@ -69,7 +69,7 @@ public:
stream<NextLayer, deflateSupported>& ws,
close_reason const& cr)
: stable_async_op_base<
Handler, beast::detail::get_executor_type<stream>>(
Handler, beast::executor_type<stream>>(
std::forward<Handler_>(h), ws.get_executor())
, d_(beast::allocate_stable<state>(
*this, ws, cr))
@@ -16,8 +16,8 @@
#include <boost/beast/http/read.hpp>
#include <boost/beast/http/write.hpp>
#include <boost/beast/core/async_op_base.hpp>
#include <boost/beast/core/stream_traits.hpp>
#include <boost/beast/core/type_traits.hpp>
#include <boost/beast/core/detail/get_executor_type.hpp>
#include <boost/asio/coroutine.hpp>
#include <boost/assert.hpp>
#include <boost/throw_exception.hpp>
@@ -35,7 +35,7 @@ template<class NextLayer, bool deflateSupported>
template<class Handler>
class stream<NextLayer, deflateSupported>::handshake_op
: public beast::stable_async_op_base<Handler,
beast::detail::get_executor_type<stream>>
beast::executor_type<stream>>
, public net::coroutine
{
struct data
@@ -72,7 +72,7 @@ public:
Handler_&& h,
stream& ws, Args&&... args)
: stable_async_op_base<Handler,
beast::detail::get_executor_type<stream>>(
beast::executor_type<stream>>(
std::forward<Handler_>(h), ws.get_executor())
, d_(beast::allocate_stable<data>(
*this, ws, std::forward<Args>(args)...))
+3 -3
View File
@@ -12,8 +12,8 @@
#include <boost/beast/core/async_op_base.hpp>
#include <boost/beast/core/bind_handler.hpp>
#include <boost/beast/core/stream_traits.hpp>
#include <boost/beast/core/type_traits.hpp>
#include <boost/beast/core/detail/get_executor_type.hpp>
#include <boost/beast/websocket/detail/frame.hpp>
#include <boost/asio/coroutine.hpp>
#include <boost/asio/post.hpp>
@@ -33,7 +33,7 @@ template<class NextLayer, bool deflateSupported>
template<class Handler>
class stream<NextLayer, deflateSupported>::ping_op
: public beast::stable_async_op_base<
Handler, beast::detail::get_executor_type<stream>>
Handler, beast::executor_type<stream>>
, public net::coroutine
{
struct state
@@ -66,7 +66,7 @@ public:
detail::opcode op,
ping_data const& payload)
: stable_async_op_base<
Handler, beast::detail::get_executor_type<stream>>(
Handler, beast::executor_type<stream>>(
std::forward<Handler_>(h), ws.get_executor())
, d_(beast::allocate_stable<state>(
*this, ws, op, payload))
+5 -5
View File
@@ -18,11 +18,11 @@
#include <boost/beast/core/buffers_prefix.hpp>
#include <boost/beast/core/buffers_suffix.hpp>
#include <boost/beast/core/flat_static_buffer.hpp>
#include <boost/beast/core/stream_traits.hpp>
#include <boost/beast/core/type_traits.hpp>
#include <boost/beast/core/detail/buffer.hpp>
#include <boost/beast/core/detail/clamp.hpp>
#include <boost/beast/core/detail/config.hpp>
#include <boost/beast/core/detail/get_executor_type.hpp>
#include <boost/asio/coroutine.hpp>
#include <boost/asio/post.hpp>
#include <boost/assert.hpp>
@@ -47,7 +47,7 @@ template<
class Handler>
class stream<NextLayer, deflateSupported>::read_some_op
: public beast::async_op_base<
Handler, beast::detail::get_executor_type<stream>>
Handler, beast::executor_type<stream>>
, public net::coroutine
{
stream& ws_;
@@ -68,7 +68,7 @@ public:
stream<NextLayer, deflateSupported>& ws,
MutableBufferSequence const& bs)
: async_op_base<
Handler, beast::detail::get_executor_type<stream>>(
Handler, beast::executor_type<stream>>(
std::forward<Handler_>(h), ws.get_executor())
, ws_(ws)
, bs_(bs)
@@ -631,7 +631,7 @@ template<
class Handler>
class stream<NextLayer, deflateSupported>::read_op
: public beast::async_op_base<
Handler, beast::detail::get_executor_type<stream>>
Handler, beast::executor_type<stream>>
, public net::coroutine
{
stream<NextLayer, deflateSupported>& ws_;
@@ -649,7 +649,7 @@ public:
std::size_t limit,
bool some)
: async_op_base<
Handler, beast::detail::get_executor_type<stream>>(
Handler, beast::executor_type<stream>>(
std::forward<Handler_>(h), ws.get_executor())
, ws_(ws)
, b_(b)
@@ -12,8 +12,8 @@
#include <boost/beast/core/async_op_base.hpp>
#include <boost/beast/core/bind_handler.hpp>
#include <boost/beast/core/stream_traits.hpp>
#include <boost/beast/core/type_traits.hpp>
#include <boost/beast/core/detail/get_executor_type.hpp>
#include <boost/asio/coroutine.hpp>
#include <boost/asio/post.hpp>
#include <memory>
@@ -27,7 +27,7 @@ namespace detail {
template<class Handler>
class teardown_tcp_op
: public beast::async_op_base<
Handler, beast::detail::get_executor_type<
Handler, beast::executor_type<
net::ip::tcp::socket>>
, public net::coroutine
{
@@ -44,7 +44,7 @@ public:
socket_type& s,
role_type role)
: async_op_base<Handler,
beast::detail::get_executor_type<
beast::executor_type<
net::ip::tcp::socket>>(
std::forward<Handler_>(h), s.get_executor())
, s_(s)
+3 -3
View File
@@ -19,10 +19,10 @@
#include <boost/beast/core/buffers_range.hpp>
#include <boost/beast/core/buffers_suffix.hpp>
#include <boost/beast/core/flat_static_buffer.hpp>
#include <boost/beast/core/stream_traits.hpp>
#include <boost/beast/core/type_traits.hpp>
#include <boost/beast/core/detail/clamp.hpp>
#include <boost/beast/core/detail/config.hpp>
#include <boost/beast/core/detail/get_executor_type.hpp>
#include <boost/beast/websocket/detail/frame.hpp>
#include <boost/asio/coroutine.hpp>
#include <boost/assert.hpp>
@@ -39,7 +39,7 @@ template<class NextLayer, bool deflateSupported>
template<class Buffers, class Handler>
class stream<NextLayer, deflateSupported>::write_some_op
: public beast::async_op_base<
Handler, beast::detail::get_executor_type<stream>>
Handler, beast::executor_type<stream>>
, public net::coroutine
{
stream& ws_;
@@ -64,7 +64,7 @@ public:
bool fin,
Buffers const& bs)
: beast::async_op_base<Handler,
beast::detail::get_executor_type<stream>>(
beast::executor_type<stream>>(
std::forward<Handler_>(h), ws.get_executor())
, ws_(ws)
, cb_(bs)