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:
Damian Jarek authored and Vinnie Falco committed 2017-12-04 12:14:40 -08:00
1 parent 3361df142c
commit 200e898f7e
15 files changed
+69 -75

No files matched your search

+13 -24
View File
@@ -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))
{
}