forked from boostorg/beast
Don't copy completion handlers:
All asynchronous operations will now be able to use move-only CompletionHandlers. Signed-off-by: Damian Jarek <damian.jarek93@gmail.com>
This commit is contained in:
1 parent
3361df142c
commit
200e898f7e
15 files changed
+69
-75
No files matched your search
@@ -24,7 +24,7 @@ namespace http {
|
||||
class fields_test : public beast::unit_test::suite
|
||||
{
|
||||
public:
|
||||
template <class T>
|
||||
template<class T>
|
||||
class test_allocator
|
||||
{
|
||||
public:
|
||||
@@ -32,7 +32,8 @@ public:
|
||||
|
||||
test_allocator() noexcept(false) {}
|
||||
|
||||
template <typename U, typename = typename std::enable_if<!std::is_same<test_allocator, U>::value>::type>
|
||||
template<class U, class = typename
|
||||
std::enable_if<!std::is_same<test_allocator, U>::value>::type>
|
||||
test_allocator(test_allocator<U> const&) noexcept {}
|
||||
|
||||
value_type*
|
||||
@@ -55,7 +56,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class U>
|
||||
template<class U>
|
||||
friend
|
||||
bool
|
||||
operator!=(test_allocator<T> const& x, test_allocator<U> const& y) noexcept
|
||||
|
||||
@@ -488,7 +488,7 @@ async_read_some(
|
||||
return boost::asio::post(
|
||||
in_->ioc.get_executor(),
|
||||
bind_handler(
|
||||
init.completion_handler,
|
||||
std::move(init.completion_handler),
|
||||
ec,
|
||||
0));
|
||||
}
|
||||
@@ -506,7 +506,7 @@ async_read_some(
|
||||
boost::asio::post(
|
||||
in_->ioc.get_executor(),
|
||||
bind_handler(
|
||||
init.completion_handler,
|
||||
std::move(init.completion_handler),
|
||||
error_code{},
|
||||
bytes_transferred));
|
||||
}
|
||||
@@ -522,7 +522,7 @@ async_read_some(
|
||||
boost::asio::post(
|
||||
in_->ioc.get_executor(),
|
||||
bind_handler(
|
||||
init.completion_handler,
|
||||
std::move(init.completion_handler),
|
||||
ec,
|
||||
0));
|
||||
}
|
||||
@@ -531,7 +531,7 @@ async_read_some(
|
||||
in_->op.reset(new read_op_impl<BOOST_ASIO_HANDLER_TYPE(
|
||||
ReadHandler, void(error_code, std::size_t)),
|
||||
MutableBufferSequence>{*in_, buffers,
|
||||
init.completion_handler});
|
||||
std::move(init.completion_handler)});
|
||||
}
|
||||
}
|
||||
return init.result.get();
|
||||
@@ -605,7 +605,7 @@ async_write_some(ConstBufferSequence const& buffers,
|
||||
return boost::asio::post(
|
||||
in_->ioc.get_executor(),
|
||||
bind_handler(
|
||||
init.completion_handler,
|
||||
std::move(init.completion_handler),
|
||||
boost::asio::error::connection_reset,
|
||||
0));
|
||||
BOOST_ASSERT(out->code == status::ok);
|
||||
@@ -616,7 +616,7 @@ async_write_some(ConstBufferSequence const& buffers,
|
||||
return boost::asio::post(
|
||||
in_->ioc.get_executor(),
|
||||
bind_handler(
|
||||
init.completion_handler,
|
||||
std::move(init.completion_handler),
|
||||
ec,
|
||||
0));
|
||||
}
|
||||
@@ -632,7 +632,7 @@ async_write_some(ConstBufferSequence const& buffers,
|
||||
boost::asio::post(
|
||||
in_->ioc.get_executor(),
|
||||
bind_handler(
|
||||
init.completion_handler,
|
||||
std::move(init.completion_handler),
|
||||
error_code{},
|
||||
bytes_transferred));
|
||||
return init.result.get();
|
||||
@@ -702,18 +702,11 @@ class stream::read_op_impl : public stream::read_op
|
||||
lambda(lambda&&) = default;
|
||||
lambda(lambda const&) = default;
|
||||
|
||||
lambda(state& s, Buffers const& b, Handler&& h)
|
||||
template<class DeducedHandler>
|
||||
lambda(state& s, Buffers const& b, DeducedHandler&& h)
|
||||
: s_(s)
|
||||
, b_(b)
|
||||
, h_(std::move(h))
|
||||
, work_(s_.ioc.get_executor())
|
||||
{
|
||||
}
|
||||
|
||||
lambda(state& s, Buffers const& b, Handler const& h)
|
||||
: s_(s)
|
||||
, b_(b)
|
||||
, h_(h)
|
||||
, h_(std::forward<DeducedHandler>(h))
|
||||
, work_(s_.ioc.get_executor())
|
||||
{
|
||||
}
|
||||
@@ -772,13 +765,9 @@ class stream::read_op_impl : public stream::read_op
|
||||
lambda fn_;
|
||||
|
||||
public:
|
||||
read_op_impl(state& s, Buffers const& b, Handler&& h)
|
||||
: fn_(s, b, std::move(h))
|
||||
{
|
||||
}
|
||||
|
||||
read_op_impl(state& s, Buffers const& b, Handler const& h)
|
||||
: fn_(s, b, h)
|
||||
template<class DeducedHandler>
|
||||
read_op_impl(state& s, Buffers const& b, DeducedHandler&& h)
|
||||
: fn_(s, b, std::forward<DeducedHandler>(h))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user