get_executor() works on initiation objects

This is required for the new `asio::cancel_at` and `asio::cancel_after`
completion token adapters to work.
This commit is contained in:
Mohammad Nejati
2024-07-04 10:24:42 +00:00
committed by Mohammad Nejati
parent 1a2b85b7a4
commit 75812db90a
16 changed files with 344 additions and 158 deletions

View File

@ -167,11 +167,20 @@ public:
struct run_read_op struct run_read_op
{ {
icy_stream* self;
using executor_type = typename icy_stream::executor_type;
executor_type
get_executor() const noexcept
{
return self->get_executor();
}
template<class ReadHandler, class Buffers> template<class ReadHandler, class Buffers>
void void
operator()( operator()(
ReadHandler&& h, ReadHandler&& h,
icy_stream* s,
Buffers const& b) Buffers const& b)
{ {
// If you get an error on the following line it means // If you get an error on the following line it means
@ -186,7 +195,7 @@ struct run_read_op
read_op< read_op<
Buffers, Buffers,
typename std::decay<ReadHandler>::type>( typename std::decay<ReadHandler>::type>(
std::forward<ReadHandler>(h), *s, b); std::forward<ReadHandler>(h), *self, b);
} }
}; };
@ -292,9 +301,8 @@ async_read_some(
return net::async_initiate< return net::async_initiate<
ReadHandler, ReadHandler,
void(error_code, std::size_t)>( void(error_code, std::size_t)>(
typename ops::run_read_op{}, typename ops::run_read_op{this},
handler, handler,
this,
buffers); buffers);
} }

View File

@ -27,7 +27,27 @@ namespace boost {
namespace beast { namespace beast {
namespace test { namespace test {
//------------------------------------------------------------------------------ namespace detail
{
template<class To>
struct extract_executor_op
{
To operator()(net::any_io_executor& ex) const
{
assert(ex.template target<To>());
return *ex.template target<To>();
}
};
template<>
struct extract_executor_op<net::any_io_executor>
{
net::any_io_executor operator()(net::any_io_executor& ex) const
{
return ex;
}
};
} // detail
template<class Executor> template<class Executor>
template<class Handler, class Buffers> template<class Handler, class Buffers>
@ -163,13 +183,22 @@ public:
template<class Executor> template<class Executor>
struct basic_stream<Executor>::run_read_op struct basic_stream<Executor>::run_read_op
{ {
boost::shared_ptr<detail::stream_state> const& in;
using executor_type = typename basic_stream::executor_type;
executor_type
get_executor() const noexcept
{
return detail::extract_executor_op<Executor>()(in->exec);
}
template< template<
class ReadHandler, class ReadHandler,
class MutableBufferSequence> class MutableBufferSequence>
void void
operator()( operator()(
ReadHandler&& h, ReadHandler&& h,
boost::shared_ptr<detail::stream_state> const& in,
MutableBufferSequence const& buffers) MutableBufferSequence const& buffers)
{ {
// If you get an error on the following line it means // If you get an error on the following line it means
@ -197,13 +226,22 @@ struct basic_stream<Executor>::run_read_op
template<class Executor> template<class Executor>
struct basic_stream<Executor>::run_write_op struct basic_stream<Executor>::run_write_op
{ {
boost::shared_ptr<detail::stream_state> const& in_;
using executor_type = typename basic_stream::executor_type;
executor_type
get_executor() const noexcept
{
return detail::extract_executor_op<Executor>()(in_->exec);
}
template< template<
class WriteHandler, class WriteHandler,
class ConstBufferSequence> class ConstBufferSequence>
void void
operator()( operator()(
WriteHandler&& h, WriteHandler&& h,
boost::shared_ptr<detail::stream_state> in_,
boost::weak_ptr<detail::stream_state> out_, boost::weak_ptr<detail::stream_state> out_,
ConstBufferSequence const& buffers) ConstBufferSequence const& buffers)
{ {
@ -336,9 +374,8 @@ async_read_some(
return net::async_initiate< return net::async_initiate<
ReadHandler, ReadHandler,
void(error_code, std::size_t)>( void(error_code, std::size_t)>(
run_read_op{}, run_read_op{in_},
handler, handler,
in_,
buffers); buffers);
} }
@ -420,9 +457,8 @@ async_write_some(
return net::async_initiate< return net::async_initiate<
WriteHandler, WriteHandler,
void(error_code, std::size_t)>( void(error_code, std::size_t)>(
run_write_op{}, run_write_op{in_},
handler, handler,
in_,
out_, out_,
buffers); buffers);
} }
@ -467,28 +503,6 @@ connect(stream& to, Arg1&& arg1, ArgN&&... argn)
return from; return from;
} }
namespace detail
{
template<class To>
struct extract_executor_op
{
To operator()(net::any_io_executor& ex) const
{
assert(ex.template target<To>());
return *ex.template target<To>();
}
};
template<>
struct extract_executor_op<net::any_io_executor>
{
net::any_io_executor operator()(net::any_io_executor& ex) const
{
return ex;
}
};
}
template<class Executor> template<class Executor>
auto basic_stream<Executor>::get_executor() noexcept -> executor_type auto basic_stream<Executor>::get_executor() noexcept -> executor_type
{ {

View File

@ -104,17 +104,26 @@ public:
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
template <typename AsyncReadStream>
struct run_read_op struct run_read_op
{ {
AsyncReadStream* stream;
using executor_type = typename AsyncReadStream::executor_type;
executor_type
get_executor() const noexcept
{
return stream->get_executor();
}
template< template<
class AsyncReadStream,
class DynamicBuffer, class DynamicBuffer,
class Condition, class Condition,
class ReadHandler> class ReadHandler>
void void
operator()( operator()(
ReadHandler&& h, ReadHandler&& h,
AsyncReadStream* s,
DynamicBuffer* b, DynamicBuffer* b,
Condition&& c) Condition&& c)
{ {
@ -133,7 +142,7 @@ struct run_read_op
typename std::decay<Condition>::type, typename std::decay<Condition>::type,
typename std::decay<ReadHandler>::type>( typename std::decay<ReadHandler>::type>(
std::forward<ReadHandler>(h), std::forward<ReadHandler>(h),
*s, *stream,
*b, *b,
std::forward<Condition>(c)); std::forward<Condition>(c));
} }
@ -234,9 +243,8 @@ async_read(
return net::async_initiate< return net::async_initiate<
ReadHandler, ReadHandler,
void(error_code, std::size_t)>( void(error_code, std::size_t)>(
typename dynamic_read_ops::run_read_op{}, typename dynamic_read_ops::run_read_op<AsyncReadStream>{&stream},
handler, handler,
&stream,
&buffer, &buffer,
std::forward<CompletionCondition>(cond)); std::forward<CompletionCondition>(cond));
} }

View File

@ -348,6 +348,7 @@ class detect_ssl_op;
// authors of composed operations need to write it this way to get the // authors of composed operations need to write it this way to get the
// very best performance, for example when using Coroutines TS (`co_await`). // very best performance, for example when using Coroutines TS (`co_await`).
template <typename AsyncReadStream>
struct run_detect_ssl_op struct run_detect_ssl_op
{ {
// The implementation of `net::async_initiate` captures the // The implementation of `net::async_initiate` captures the
@ -361,20 +362,29 @@ struct run_detect_ssl_op
// token into the "real handler" which must have the correct // token into the "real handler" which must have the correct
// signature, in this case `void(error_code, boost::tri_bool)`. // signature, in this case `void(error_code, boost::tri_bool)`.
AsyncReadStream* stream;
using executor_type = typename AsyncReadStream::executor_type;
executor_type
get_executor() const noexcept
{
return stream->get_executor();
}
template< template<
class DetectHandler, class DetectHandler,
class AsyncReadStream,
class DynamicBuffer> class DynamicBuffer>
void operator()( void
operator()(
DetectHandler&& h, DetectHandler&& h,
AsyncReadStream* s, // references are passed as pointers
DynamicBuffer* b) DynamicBuffer* b)
{ {
detect_ssl_op< detect_ssl_op<
typename std::decay<DetectHandler>::type, typename std::decay<DetectHandler>::type,
AsyncReadStream, AsyncReadStream,
DynamicBuffer>( DynamicBuffer>(
std::forward<DetectHandler>(h), *s, *b); std::forward<DetectHandler>(h), *stream, *b);
} }
}; };
@ -423,9 +433,8 @@ async_detect_ssl(
return net::async_initiate< return net::async_initiate<
CompletionToken, CompletionToken,
void(error_code, bool)>( void(error_code, bool)>(
detail::run_detect_ssl_op{}, detail::run_detect_ssl_op<AsyncReadStream>{&stream},
token, token,
&stream, // pass the reference by pointer
&buffer); &buffer);
} }

View File

@ -606,11 +606,20 @@ public:
struct run_read_op struct run_read_op
{ {
basic_stream* self;
using executor_type = typename basic_stream::executor_type;
executor_type
get_executor() const noexcept
{
return self->get_executor();
}
template<class ReadHandler, class Buffers> template<class ReadHandler, class Buffers>
void void
operator()( operator()(
ReadHandler&& h, ReadHandler&& h,
basic_stream* s,
Buffers const& b) Buffers const& b)
{ {
// If you get an error on the following line it means // If you get an error on the following line it means
@ -626,17 +635,26 @@ struct run_read_op
true, true,
Buffers, Buffers,
typename std::decay<ReadHandler>::type>( typename std::decay<ReadHandler>::type>(
std::forward<ReadHandler>(h), *s, b); std::forward<ReadHandler>(h), *self, b);
} }
}; };
struct run_write_op struct run_write_op
{ {
basic_stream* self;
using executor_type = typename basic_stream::executor_type;
executor_type
get_executor() const noexcept
{
return self->get_executor();
}
template<class WriteHandler, class Buffers> template<class WriteHandler, class Buffers>
void void
operator()( operator()(
WriteHandler&& h, WriteHandler&& h,
basic_stream* s,
Buffers const& b) Buffers const& b)
{ {
// If you get an error on the following line it means // If you get an error on the following line it means
@ -652,17 +670,26 @@ struct run_write_op
false, false,
Buffers, Buffers,
typename std::decay<WriteHandler>::type>( typename std::decay<WriteHandler>::type>(
std::forward<WriteHandler>(h), *s, b); std::forward<WriteHandler>(h), *self, b);
} }
}; };
struct run_connect_op struct run_connect_op
{ {
basic_stream* self;
using executor_type = typename basic_stream::executor_type;
executor_type
get_executor() const noexcept
{
return self->get_executor();
}
template<class ConnectHandler> template<class ConnectHandler>
void void
operator()( operator()(
ConnectHandler&& h, ConnectHandler&& h,
basic_stream* s,
endpoint_type const& ep) endpoint_type const& ep)
{ {
// If you get an error on the following line it means // If you get an error on the following line it means
@ -675,12 +702,22 @@ struct run_connect_op
"ConnectHandler type requirements not met"); "ConnectHandler type requirements not met");
connect_op<typename std::decay<ConnectHandler>::type>( connect_op<typename std::decay<ConnectHandler>::type>(
std::forward<ConnectHandler>(h), *s, ep); std::forward<ConnectHandler>(h), *self, ep);
} }
}; };
struct run_connect_range_op struct run_connect_range_op
{ {
basic_stream* self;
using executor_type = typename basic_stream::executor_type;
executor_type
get_executor() const noexcept
{
return self->get_executor();
}
template< template<
class RangeConnectHandler, class RangeConnectHandler,
class EndpointSequence, class EndpointSequence,
@ -688,7 +725,6 @@ struct run_connect_range_op
void void
operator()( operator()(
RangeConnectHandler&& h, RangeConnectHandler&& h,
basic_stream* s,
EndpointSequence const& eps, EndpointSequence const& eps,
Condition const& cond) Condition const& cond)
{ {
@ -702,12 +738,22 @@ struct run_connect_range_op
"RangeConnectHandler type requirements not met"); "RangeConnectHandler type requirements not met");
connect_op<typename std::decay<RangeConnectHandler>::type>( connect_op<typename std::decay<RangeConnectHandler>::type>(
std::forward<RangeConnectHandler>(h), *s, eps, cond); std::forward<RangeConnectHandler>(h), *self, eps, cond);
} }
}; };
struct run_connect_iter_op struct run_connect_iter_op
{ {
basic_stream* self;
using executor_type = typename basic_stream::executor_type;
executor_type
get_executor() const noexcept
{
return self->get_executor();
}
template< template<
class IteratorConnectHandler, class IteratorConnectHandler,
class Iterator, class Iterator,
@ -715,7 +761,6 @@ struct run_connect_iter_op
void void
operator()( operator()(
IteratorConnectHandler&& h, IteratorConnectHandler&& h,
basic_stream* s,
Iterator begin, Iterator end, Iterator begin, Iterator end,
Condition const& cond) Condition const& cond)
{ {
@ -729,7 +774,7 @@ struct run_connect_iter_op
"IteratorConnectHandler type requirements not met"); "IteratorConnectHandler type requirements not met");
connect_op<typename std::decay<IteratorConnectHandler>::type>( connect_op<typename std::decay<IteratorConnectHandler>::type>(
std::forward<IteratorConnectHandler>(h), *s, begin, end, cond); std::forward<IteratorConnectHandler>(h), *self, begin, end, cond);
} }
}; };
@ -895,9 +940,8 @@ async_connect(
return net::async_initiate< return net::async_initiate<
ConnectHandler, ConnectHandler,
void(error_code)>( void(error_code)>(
typename ops::run_connect_op{}, typename ops::run_connect_op{this},
handler, handler,
this,
ep); ep);
} }
@ -916,9 +960,8 @@ async_connect(
return net::async_initiate< return net::async_initiate<
RangeConnectHandler, RangeConnectHandler,
void(error_code, typename Protocol::endpoint)>( void(error_code, typename Protocol::endpoint)>(
typename ops::run_connect_range_op{}, typename ops::run_connect_range_op{this},
handler, handler,
this,
endpoints, endpoints,
detail::any_endpoint{}); detail::any_endpoint{});
} }
@ -940,9 +983,8 @@ async_connect(
return net::async_initiate< return net::async_initiate<
RangeConnectHandler, RangeConnectHandler,
void(error_code, typename Protocol::endpoint)>( void(error_code, typename Protocol::endpoint)>(
typename ops::run_connect_range_op{}, typename ops::run_connect_range_op{this},
handler, handler,
this,
endpoints, endpoints,
connect_condition); connect_condition);
} }
@ -961,9 +1003,8 @@ async_connect(
return net::async_initiate< return net::async_initiate<
IteratorConnectHandler, IteratorConnectHandler,
void(error_code, Iterator)>( void(error_code, Iterator)>(
typename ops::run_connect_iter_op{}, typename ops::run_connect_iter_op{this},
handler, handler,
this,
begin, end, begin, end,
detail::any_endpoint{}); detail::any_endpoint{});
} }
@ -984,9 +1025,8 @@ async_connect(
return net::async_initiate< return net::async_initiate<
IteratorConnectHandler, IteratorConnectHandler,
void(error_code, Iterator)>( void(error_code, Iterator)>(
typename ops::run_connect_iter_op{}, typename ops::run_connect_iter_op{this},
handler, handler,
this,
begin, end, begin, end,
connect_condition); connect_condition);
} }
@ -1007,9 +1047,8 @@ async_read_some(
return net::async_initiate< return net::async_initiate<
ReadHandler, ReadHandler,
void(error_code, std::size_t)>( void(error_code, std::size_t)>(
typename ops::run_read_op{}, typename ops::run_read_op{this},
handler, handler,
this,
buffers); buffers);
} }
@ -1027,9 +1066,8 @@ async_write_some(
return net::async_initiate< return net::async_initiate<
WriteHandler, WriteHandler,
void(error_code, std::size_t)>( void(error_code, std::size_t)>(
typename ops::run_write_op{}, typename ops::run_write_op{this},
handler, handler,
this,
buffers); buffers);
} }

View File

@ -106,11 +106,20 @@ public:
struct run_read_op struct run_read_op
{ {
buffered_read_stream* self;
using executor_type = typename buffered_read_stream::executor_type;
executor_type
get_executor() const noexcept
{
return self->get_executor();
}
template<class ReadHandler, class Buffers> template<class ReadHandler, class Buffers>
void void
operator()( operator()(
ReadHandler&& h, ReadHandler&& h,
buffered_read_stream* s,
Buffers const* b) Buffers const* b)
{ {
// If you get an error on the following line it means // If you get an error on the following line it means
@ -125,7 +134,7 @@ struct run_read_op
read_op< read_op<
Buffers, Buffers,
typename std::decay<ReadHandler>::type>( typename std::decay<ReadHandler>::type>(
std::forward<ReadHandler>(h), *s, *b); std::forward<ReadHandler>(h), *self, *b);
} }
}; };
@ -231,9 +240,8 @@ async_read_some(
return net::async_initiate< return net::async_initiate<
ReadHandler, ReadHandler,
void(error_code, std::size_t)>( void(error_code, std::size_t)>(
typename ops::run_read_op{}, typename ops::run_read_op{this},
handler, handler,
this,
&buffers); &buffers);
} }

View File

@ -85,11 +85,20 @@ public:
struct run_write_op struct run_write_op
{ {
flat_stream* self;
using executor_type = typename flat_stream::executor_type;
executor_type
get_executor() const noexcept
{
return self->get_executor();
}
template<class WriteHandler, class Buffers> template<class WriteHandler, class Buffers>
void void
operator()( operator()(
WriteHandler&& h, WriteHandler&& h,
flat_stream* s,
Buffers const& b) Buffers const& b)
{ {
// If you get an error on the following line it means // If you get an error on the following line it means
@ -103,7 +112,7 @@ struct run_write_op
write_op< write_op<
typename std::decay<WriteHandler>::type>( typename std::decay<WriteHandler>::type>(
std::forward<WriteHandler>(h), *s, b); std::forward<WriteHandler>(h), *self, b);
} }
}; };
@ -250,9 +259,8 @@ async_write_some(
return net::async_initiate< return net::async_initiate<
WriteHandler, WriteHandler,
void(error_code, std::size_t)>( void(error_code, std::size_t)>(
typename ops::run_write_op{}, typename ops::run_write_op{this},
handler, handler,
this,
buffers); buffers);
} }

View File

@ -509,17 +509,23 @@ public:
} }
}; };
template<class Protocol, class Executor>
struct run_write_some_win32_op struct run_write_some_win32_op
{ {
template< net::basic_stream_socket<Protocol, Executor>* stream;
class Protocol, class Executor,
bool isRequest, class Fields, using executor_type = typename net::basic_stream_socket<Protocol, Executor>::executor_type;
class WriteHandler>
executor_type
get_executor() const noexcept
{
return stream->get_executor();
}
template<bool isRequest, class Fields, class WriteHandler>
void void
operator()( operator()(
WriteHandler&& h, WriteHandler&& h,
net::basic_stream_socket<
Protocol, Executor>* s,
serializer<isRequest, serializer<isRequest,
basic_file_body<file_win32>, Fields>* sr) basic_file_body<file_win32>, Fields>* sr)
{ {
@ -536,7 +542,7 @@ struct run_write_some_win32_op
Protocol, Executor, Protocol, Executor,
isRequest, Fields, isRequest, Fields,
typename std::decay<WriteHandler>::type>( typename std::decay<WriteHandler>::type>(
std::forward<WriteHandler>(h), *s, *sr); std::forward<WriteHandler>(h), *stream, *sr);
} }
}; };
@ -629,9 +635,8 @@ async_write_some(
return net::async_initiate< return net::async_initiate<
WriteHandler, WriteHandler,
void(error_code, std::size_t)>( void(error_code, std::size_t)>(
detail::run_write_some_win32_op{}, detail::run_write_some_win32_op<Protocol, Executor>{&sock},
handler, handler,
&sock,
&sr); &sr);
} }

View File

@ -116,17 +116,26 @@ public:
} }
}; };
template <typename AsyncReadStream>
struct run_read_msg_op struct run_read_msg_op
{ {
AsyncReadStream* stream;
using executor_type = typename AsyncReadStream::executor_type;
executor_type
get_executor() const noexcept
{
return stream->get_executor();
}
template< template<
class ReadHandler, class ReadHandler,
class AsyncReadStream,
class DynamicBuffer, class DynamicBuffer,
bool isRequest, class Body, class Allocator> bool isRequest, class Body, class Allocator>
void void
operator()( operator()(
ReadHandler&& h, ReadHandler&& h,
AsyncReadStream* s,
DynamicBuffer* b, DynamicBuffer* b,
message<isRequest, Body, message<isRequest, Body,
basic_fields<Allocator>>* m) basic_fields<Allocator>>* m)
@ -145,7 +154,7 @@ struct run_read_msg_op
DynamicBuffer, DynamicBuffer,
isRequest, Body, Allocator, isRequest, Body, Allocator,
typename std::decay<ReadHandler>::type>( typename std::decay<ReadHandler>::type>(
std::forward<ReadHandler>(h), *s, *b, *m); std::forward<ReadHandler>(h), *stream, *b, *m);
} }
}; };
@ -710,8 +719,8 @@ async_read(
return net::async_initiate< return net::async_initiate<
ReadHandler, ReadHandler,
void(error_code, std::size_t)>( void(error_code, std::size_t)>(
detail::run_read_msg_op{}, detail::run_read_msg_op<AsyncReadStream>{&stream},
handler, &stream, &buffer, &msg); handler, &buffer, &msg);
} }
} // http } // http

View File

@ -299,16 +299,25 @@ public:
} }
}; };
template <typename AsyncWriteStream>
struct run_write_some_op struct run_write_some_op
{ {
AsyncWriteStream* stream;
using executor_type = typename AsyncWriteStream::executor_type;
executor_type
get_executor() const noexcept
{
return stream->get_executor();
}
template< template<
class WriteHandler, class WriteHandler,
class Stream,
bool isRequest, class Body, class Fields> bool isRequest, class Body, class Fields>
void void
operator()( operator()(
WriteHandler&& h, WriteHandler&& h,
Stream* s,
serializer<isRequest, Body, Fields>* sr) serializer<isRequest, Body, Fields>* sr)
{ {
// If you get an error on the following line it means // If you get an error on the following line it means
@ -322,23 +331,32 @@ struct run_write_some_op
write_some_op< write_some_op<
typename std::decay<WriteHandler>::type, typename std::decay<WriteHandler>::type,
Stream, AsyncWriteStream,
isRequest, Body, Fields>( isRequest, Body, Fields>(
std::forward<WriteHandler>(h), *s, *sr); std::forward<WriteHandler>(h), *stream, *sr);
} }
}; };
template <typename AsyncWriteStream>
struct run_write_op struct run_write_op
{ {
AsyncWriteStream* stream;
using executor_type = typename AsyncWriteStream::executor_type;
executor_type
get_executor() const noexcept
{
return stream->get_executor();
}
template< template<
class WriteHandler, class WriteHandler,
class Stream,
class Predicate, class Predicate,
bool isRequest, class Body, class Fields> bool isRequest, class Body, class Fields>
void void
operator()( operator()(
WriteHandler&& h, WriteHandler&& h,
Stream* s,
Predicate const&, Predicate const&,
serializer<isRequest, Body, Fields>* sr) serializer<isRequest, Body, Fields>* sr)
{ {
@ -353,24 +371,33 @@ struct run_write_op
write_op< write_op<
typename std::decay<WriteHandler>::type, typename std::decay<WriteHandler>::type,
Stream, AsyncWriteStream,
Predicate, Predicate,
isRequest, Body, Fields>( isRequest, Body, Fields>(
std::forward<WriteHandler>(h), *s, *sr); std::forward<WriteHandler>(h), *stream, *sr);
} }
}; };
template <typename AsyncWriteStream>
struct run_write_msg_op struct run_write_msg_op
{ {
AsyncWriteStream* stream;
using executor_type = typename AsyncWriteStream::executor_type;
executor_type
get_executor() const noexcept
{
return stream->get_executor();
}
template< template<
class WriteHandler, class WriteHandler,
class Stream,
bool isRequest, class Body, class Fields, bool isRequest, class Body, class Fields,
class... Args> class... Args>
void void
operator()( operator()(
WriteHandler&& h, WriteHandler&& h,
Stream* s,
message<isRequest, Body, Fields>* m, message<isRequest, Body, Fields>* m,
std::false_type, std::false_type,
Args&&... args) Args&&... args)
@ -386,21 +413,19 @@ struct run_write_msg_op
write_msg_op< write_msg_op<
typename std::decay<WriteHandler>::type, typename std::decay<WriteHandler>::type,
Stream, AsyncWriteStream,
isRequest, Body, Fields>( isRequest, Body, Fields>(
std::forward<WriteHandler>(h), *s, *m, std::forward<WriteHandler>(h), *stream, *m,
std::forward<Args>(args)...); std::forward<Args>(args)...);
} }
template< template<
class WriteHandler, class WriteHandler,
class Stream,
bool isRequest, class Body, class Fields, bool isRequest, class Body, class Fields,
class... Args> class... Args>
void void
operator()( operator()(
WriteHandler&& h, WriteHandler&& h,
Stream* s,
message<isRequest, Body, Fields> const* m, message<isRequest, Body, Fields> const* m,
std::true_type, std::true_type,
Args&&... args) Args&&... args)
@ -416,9 +441,9 @@ struct run_write_msg_op
write_msg_op< write_msg_op<
typename std::decay<WriteHandler>::type, typename std::decay<WriteHandler>::type,
Stream, AsyncWriteStream,
isRequest, Body, Fields>( isRequest, Body, Fields>(
std::forward<WriteHandler>(h), *s, *m, std::forward<WriteHandler>(h), *stream, *m,
std::forward<Args>(args)...); std::forward<Args>(args)...);
} }
}; };
@ -513,9 +538,8 @@ async_write_some_impl(
return net::async_initiate< return net::async_initiate<
WriteHandler, WriteHandler,
void(error_code, std::size_t)>( void(error_code, std::size_t)>(
run_write_some_op{}, run_write_some_op<AsyncWriteStream>{&stream},
handler, handler,
&stream,
&sr); &sr);
} }
@ -666,9 +690,8 @@ async_write_header(
return net::async_initiate< return net::async_initiate<
WriteHandler, WriteHandler,
void(error_code, std::size_t)>( void(error_code, std::size_t)>(
detail::run_write_op{}, detail::run_write_op<AsyncWriteStream>{&stream},
handler, handler,
&stream,
detail::serializer_is_header_done{}, detail::serializer_is_header_done{},
&sr); &sr);
} }
@ -739,9 +762,8 @@ async_write(
return net::async_initiate< return net::async_initiate<
WriteHandler, WriteHandler,
void(error_code, std::size_t)>( void(error_code, std::size_t)>(
detail::run_write_op{}, detail::run_write_op<AsyncWriteStream>{&stream},
handler, handler,
&stream,
detail::serializer_is_done{}, detail::serializer_is_done{},
&sr); &sr);
} }
@ -860,9 +882,8 @@ async_write(
return net::async_initiate< return net::async_initiate<
WriteHandler, WriteHandler,
void(error_code, std::size_t)>( void(error_code, std::size_t)>(
detail::run_write_msg_op{}, detail::run_write_msg_op<AsyncWriteStream>{&stream},
handler, handler,
&stream,
&msg, &msg,
std::false_type{}); std::false_type{});
} }
@ -889,9 +910,8 @@ async_write(
return net::async_initiate< return net::async_initiate<
WriteHandler, WriteHandler,
void(error_code, std::size_t)>( void(error_code, std::size_t)>(
detail::run_write_msg_op{}, detail::run_write_msg_op<AsyncWriteStream>{&stream},
handler, handler,
&stream,
&msg, &msg,
std::true_type{}); std::true_type{});
} }

View File

@ -368,6 +368,16 @@ template<class NextLayer, bool deflateSupported>
struct stream<NextLayer, deflateSupported>:: struct stream<NextLayer, deflateSupported>::
run_response_op run_response_op
{ {
boost::shared_ptr<impl_type> const& self;
using executor_type = typename stream::executor_type;
executor_type
get_executor() const noexcept
{
return self->stream().get_executor();
}
template< template<
class AcceptHandler, class AcceptHandler,
class Body, class Allocator, class Body, class Allocator,
@ -375,7 +385,6 @@ struct stream<NextLayer, deflateSupported>::
void void
operator()( operator()(
AcceptHandler&& h, AcceptHandler&& h,
boost::shared_ptr<impl_type> const& sp,
http::request<Body, http::request<Body,
http::basic_fields<Allocator>> const* m, http::basic_fields<Allocator>> const* m,
Decorator const& d) Decorator const& d)
@ -391,7 +400,7 @@ struct stream<NextLayer, deflateSupported>::
response_op< response_op<
typename std::decay<AcceptHandler>::type>( typename std::decay<AcceptHandler>::type>(
std::forward<AcceptHandler>(h), sp, *m, d); std::forward<AcceptHandler>(h), self, *m, d);
} }
}; };
@ -399,6 +408,16 @@ template<class NextLayer, bool deflateSupported>
struct stream<NextLayer, deflateSupported>:: struct stream<NextLayer, deflateSupported>::
run_accept_op run_accept_op
{ {
boost::shared_ptr<impl_type> const& self;
using executor_type = typename stream::executor_type;
executor_type
get_executor() const noexcept
{
return self->stream().get_executor();
}
template< template<
class AcceptHandler, class AcceptHandler,
class Decorator, class Decorator,
@ -406,7 +425,6 @@ struct stream<NextLayer, deflateSupported>::
void void
operator()( operator()(
AcceptHandler&& h, AcceptHandler&& h,
boost::shared_ptr<impl_type> const& sp,
Decorator const& d, Decorator const& d,
Buffers const& b) Buffers const& b)
{ {
@ -423,7 +441,7 @@ struct stream<NextLayer, deflateSupported>::
typename std::decay<AcceptHandler>::type, typename std::decay<AcceptHandler>::type,
Decorator>( Decorator>(
std::forward<AcceptHandler>(h), std::forward<AcceptHandler>(h),
sp, self,
d, d,
b); b);
} }
@ -615,9 +633,8 @@ async_accept(
return net::async_initiate< return net::async_initiate<
AcceptHandler, AcceptHandler,
void(error_code)>( void(error_code)>(
run_accept_op{}, run_accept_op{impl_},
handler, handler,
impl_,
&default_decorate_res, &default_decorate_res,
net::const_buffer{}); net::const_buffer{});
} }
@ -648,9 +665,8 @@ async_accept(
return net::async_initiate< return net::async_initiate<
AcceptHandler, AcceptHandler,
void(error_code)>( void(error_code)>(
run_accept_op{}, run_accept_op{impl_},
handler, handler,
impl_,
&default_decorate_res, &default_decorate_res,
buffers); buffers);
} }
@ -671,9 +687,8 @@ async_accept(
return net::async_initiate< return net::async_initiate<
AcceptHandler, AcceptHandler,
void(error_code)>( void(error_code)>(
run_response_op{}, run_response_op{impl_},
handler, handler,
impl_,
&req, &req,
&default_decorate_res); &default_decorate_res);
} }

View File

@ -302,11 +302,20 @@ template<class NextLayer, bool deflateSupported>
struct stream<NextLayer, deflateSupported>:: struct stream<NextLayer, deflateSupported>::
run_close_op run_close_op
{ {
boost::shared_ptr<impl_type> const& self;
using executor_type = typename stream::executor_type;
executor_type
get_executor() const noexcept
{
return self->stream().get_executor();
}
template<class CloseHandler> template<class CloseHandler>
void void
operator()( operator()(
CloseHandler&& h, CloseHandler&& h,
boost::shared_ptr<impl_type> const& sp,
close_reason const& cr) close_reason const& cr)
{ {
// If you get an error on the following line it means // If you get an error on the following line it means
@ -321,7 +330,7 @@ struct stream<NextLayer, deflateSupported>::
close_op< close_op<
typename std::decay<CloseHandler>::type>( typename std::decay<CloseHandler>::type>(
std::forward<CloseHandler>(h), std::forward<CloseHandler>(h),
sp, self,
cr); cr);
} }
}; };
@ -458,9 +467,8 @@ async_close(close_reason const& cr, CloseHandler&& handler)
return net::async_initiate< return net::async_initiate<
CloseHandler, CloseHandler,
void(error_code)>( void(error_code)>(
run_close_op{}, run_close_op{impl_},
handler, handler,
impl_,
cr); cr);
} }

View File

@ -188,10 +188,19 @@ template<class NextLayer, bool deflateSupported>
struct stream<NextLayer, deflateSupported>:: struct stream<NextLayer, deflateSupported>::
run_handshake_op run_handshake_op
{ {
boost::shared_ptr<impl_type> const& self;
using executor_type = typename stream::executor_type;
executor_type
get_executor() const noexcept
{
return self->stream().get_executor();
}
template<class HandshakeHandler> template<class HandshakeHandler>
void operator()( void operator()(
HandshakeHandler&& h, HandshakeHandler&& h,
boost::shared_ptr<impl_type> const& sp,
request_type&& req, request_type&& req,
detail::sec_ws_key_type key, detail::sec_ws_key_type key,
response_type* res_p) response_type* res_p)
@ -208,7 +217,7 @@ struct stream<NextLayer, deflateSupported>::
handshake_op< handshake_op<
typename std::decay<HandshakeHandler>::type>( typename std::decay<HandshakeHandler>::type>(
std::forward<HandshakeHandler>(h), std::forward<HandshakeHandler>(h),
sp, std::move(req), key, res_p); self, std::move(req), key, res_p);
} }
}; };
@ -311,9 +320,8 @@ async_handshake(
return net::async_initiate< return net::async_initiate<
HandshakeHandler, HandshakeHandler,
void(error_code)>( void(error_code)>(
run_handshake_op{}, run_handshake_op{impl_},
handler, handler,
impl_,
std::move(req), std::move(req),
key, key,
nullptr); nullptr);
@ -338,9 +346,8 @@ async_handshake(
return net::async_initiate< return net::async_initiate<
HandshakeHandler, HandshakeHandler,
void(error_code)>( void(error_code)>(
run_handshake_op{}, run_handshake_op{impl_},
handler, handler,
impl_,
std::move(req), std::move(req),
key, key,
&res); &res);

View File

@ -245,11 +245,20 @@ template<class NextLayer, bool deflateSupported>
struct stream<NextLayer, deflateSupported>:: struct stream<NextLayer, deflateSupported>::
run_ping_op run_ping_op
{ {
boost::shared_ptr<impl_type> const& self;
using executor_type = typename stream::executor_type;
executor_type
get_executor() const noexcept
{
return self->stream().get_executor();
}
template<class WriteHandler> template<class WriteHandler>
void void
operator()( operator()(
WriteHandler&& h, WriteHandler&& h,
boost::shared_ptr<impl_type> const& sp,
detail::opcode op, detail::opcode op,
ping_data const& p) ping_data const& p)
{ {
@ -265,7 +274,7 @@ struct stream<NextLayer, deflateSupported>::
ping_op< ping_op<
typename std::decay<WriteHandler>::type>( typename std::decay<WriteHandler>::type>(
std::forward<WriteHandler>(h), std::forward<WriteHandler>(h),
sp, self,
op, op,
p); p);
} }
@ -336,9 +345,8 @@ async_ping(ping_data const& payload, PingHandler&& handler)
return net::async_initiate< return net::async_initiate<
PingHandler, PingHandler,
void(error_code)>( void(error_code)>(
run_ping_op{}, run_ping_op{impl_},
handler, handler,
impl_,
detail::opcode::ping, detail::opcode::ping,
payload); payload);
} }
@ -354,9 +362,8 @@ async_pong(ping_data const& payload, PongHandler&& handler)
return net::async_initiate< return net::async_initiate<
PongHandler, PongHandler,
void(error_code)>( void(error_code)>(
run_ping_op{}, run_ping_op{impl_},
handler, handler,
impl_,
detail::opcode::pong, detail::opcode::pong,
payload); payload);
} }

View File

@ -819,13 +819,22 @@ template<class NextLayer, bool deflateSupported>
struct stream<NextLayer, deflateSupported>:: struct stream<NextLayer, deflateSupported>::
run_read_some_op run_read_some_op
{ {
boost::shared_ptr<impl_type> const& self;
using executor_type = typename stream::executor_type;
executor_type
get_executor() const noexcept
{
return self->stream().get_executor();
}
template< template<
class ReadHandler, class ReadHandler,
class MutableBufferSequence> class MutableBufferSequence>
void void
operator()( operator()(
ReadHandler&& h, ReadHandler&& h,
boost::shared_ptr<impl_type> const& sp,
MutableBufferSequence const& b) MutableBufferSequence const& b)
{ {
// If you get an error on the following line it means // If you get an error on the following line it means
@ -841,7 +850,7 @@ struct stream<NextLayer, deflateSupported>::
typename std::decay<ReadHandler>::type, typename std::decay<ReadHandler>::type,
MutableBufferSequence>( MutableBufferSequence>(
std::forward<ReadHandler>(h), std::forward<ReadHandler>(h),
sp, self,
b); b);
} }
}; };
@ -850,13 +859,22 @@ template<class NextLayer, bool deflateSupported>
struct stream<NextLayer, deflateSupported>:: struct stream<NextLayer, deflateSupported>::
run_read_op run_read_op
{ {
boost::shared_ptr<impl_type> const& self;
using executor_type = typename stream::executor_type;
executor_type
get_executor() const noexcept
{
return self->stream().get_executor();
}
template< template<
class ReadHandler, class ReadHandler,
class DynamicBuffer> class DynamicBuffer>
void void
operator()( operator()(
ReadHandler&& h, ReadHandler&& h,
boost::shared_ptr<impl_type> const& sp,
DynamicBuffer* b, DynamicBuffer* b,
std::size_t limit, std::size_t limit,
bool some) bool some)
@ -874,7 +892,7 @@ struct stream<NextLayer, deflateSupported>::
typename std::decay<ReadHandler>::type, typename std::decay<ReadHandler>::type,
DynamicBuffer>( DynamicBuffer>(
std::forward<ReadHandler>(h), std::forward<ReadHandler>(h),
sp, self,
*b, *b,
limit, limit,
some); some);
@ -937,9 +955,8 @@ async_read(DynamicBuffer& buffer, ReadHandler&& handler)
return net::async_initiate< return net::async_initiate<
ReadHandler, ReadHandler,
void(error_code, std::size_t)>( void(error_code, std::size_t)>(
run_read_op{}, run_read_op{impl_},
handler, handler,
impl_,
&buffer, &buffer,
0, 0,
false); false);
@ -1014,9 +1031,8 @@ async_read_some(
return net::async_initiate< return net::async_initiate<
ReadHandler, ReadHandler,
void(error_code, std::size_t)>( void(error_code, std::size_t)>(
run_read_op{}, run_read_op{impl_},
handler, handler,
impl_,
&buffer, &buffer,
limit, limit,
true); true);
@ -1395,9 +1411,8 @@ async_read_some(
return net::async_initiate< return net::async_initiate<
ReadHandler, ReadHandler,
void(error_code, std::size_t)>( void(error_code, std::size_t)>(
run_read_some_op{}, run_read_some_op{impl_},
handler, handler,
impl_,
buffers); buffers);
} }

View File

@ -559,13 +559,22 @@ template<class NextLayer, bool deflateSupported>
struct stream<NextLayer, deflateSupported>:: struct stream<NextLayer, deflateSupported>::
run_write_some_op run_write_some_op
{ {
boost::shared_ptr<impl_type> const& self;
using executor_type = typename stream::executor_type;
executor_type
get_executor() const noexcept
{
return self->stream().get_executor();
}
template< template<
class WriteHandler, class WriteHandler,
class ConstBufferSequence> class ConstBufferSequence>
void void
operator()( operator()(
WriteHandler&& h, WriteHandler&& h,
boost::shared_ptr<impl_type> const& sp,
bool fin, bool fin,
ConstBufferSequence const& b) ConstBufferSequence const& b)
{ {
@ -582,7 +591,7 @@ struct stream<NextLayer, deflateSupported>::
typename std::decay<WriteHandler>::type, typename std::decay<WriteHandler>::type,
ConstBufferSequence>( ConstBufferSequence>(
std::forward<WriteHandler>(h), std::forward<WriteHandler>(h),
sp, self,
fin, fin,
b); b);
} }
@ -836,9 +845,8 @@ async_write_some(bool fin,
return net::async_initiate< return net::async_initiate<
WriteHandler, WriteHandler,
void(error_code, std::size_t)>( void(error_code, std::size_t)>(
run_write_some_op{}, run_write_some_op{impl_},
handler, handler,
impl_,
fin, fin,
bs); bs);
} }
@ -892,9 +900,8 @@ async_write(
return net::async_initiate< return net::async_initiate<
WriteHandler, WriteHandler,
void(error_code, std::size_t)>( void(error_code, std::size_t)>(
run_write_some_op{}, run_write_some_op{impl_},
handler, handler,
impl_,
true, true,
bs); bs);
} }