Replace beast::bind_front_handler uses with asio::prepend

This commit is contained in:
Mohammad
2023-10-27 05:52:28 +00:00
committed by Mohammad Nejati
parent 3df5d980d0
commit 0d1e2d64f8
14 changed files with 22 additions and 47 deletions

View File

@@ -10,14 +10,15 @@
#ifndef BOOST_BEAST_TEST_IMPL_STREAM_HPP
#define BOOST_BEAST_TEST_IMPL_STREAM_HPP
#include <boost/beast/core/bind_handler.hpp>
#include <boost/beast/core/buffer_traits.hpp>
#include <boost/beast/core/detail/service_base.hpp>
#include <boost/beast/core/detail/is_invocable.hpp>
#include <boost/asio/associated_cancellation_slot.hpp>
#include <boost/asio/any_io_executor.hpp>
#include <boost/asio/associated_cancellation_slot.hpp>
#include <boost/asio/dispatch.hpp>
#include <boost/asio/post.hpp>
#include <boost/asio/prepend.hpp>
#include <mutex>
#include <stdexcept>
#include <vector>
@@ -113,13 +114,11 @@ class basic_stream<Executor>::read_op : public detail::stream_read_op_base
#if defined(BOOST_ASIO_NO_TS_EXECUTORS)
net::dispatch(wg2_,
beast::bind_front_handler(std::move(h_),
ec, bytes_transferred));
net::prepend(std::move(h_), ec, bytes_transferred));
wg2_ = net::any_io_executor(); // probably unnecessary
#else // defined(BOOST_ASIO_NO_TS_EXECUTORS)
net::dispatch(wg2_.get_executor(),
beast::bind_front_handler(std::move(h_),
ec, bytes_transferred));
net::prepend(std::move(h_), ec, bytes_transferred));
wg2_.reset();
#endif // defined(BOOST_ASIO_NO_TS_EXECUTORS)
}
@@ -152,11 +151,10 @@ public:
operator()(error_code ec) override
{
#if defined(BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
net::post(wg1_.get_executor(),
beast::bind_front_handler(std::move(fn_), ec));
net::post(wg1_.get_executor(), net::prepend(std::move(fn_), ec));
wg1_.reset();
#else
net::post(wg1_, beast::bind_front_handler(std::move(fn_), ec));
net::post(wg1_, net::prepend(std::move(fn_), ec));
wg1_ = net::any_io_executor(); // probably unnecessary
#endif
}
@@ -221,9 +219,7 @@ struct basic_stream<Executor>::run_write_op
++in_->nwrite;
auto const upcall = [&](error_code ec, std::size_t n)
{
net::post(
in_->exec,
beast::bind_front_handler(std::move(h), ec, n));
net::post(in_->exec, net::prepend(std::move(h), ec, n));
};
// test failure
@@ -445,8 +441,7 @@ async_teardown(
s.in_->fc->fail(ec))
return net::post(
s.get_executor(),
beast::bind_front_handler(
std::move(handler), ec));
net::prepend(std::move(handler), ec));
s.close();
if( s.in_->fc &&
s.in_->fc->fail(ec))
@@ -456,10 +451,7 @@ async_teardown(
else
ec = {};
net::post(
s.get_executor(),
beast::bind_front_handler(
std::move(handler), ec));
net::post(s.get_executor(), net::prepend(std::move(handler), ec));
}
//------------------------------------------------------------------------------

View File

@@ -11,7 +11,6 @@
#define BOOST_BEAST_TEST_IMPL_STREAM_IPP
#include <boost/beast/_experimental/test/stream.hpp>
#include <boost/beast/core/bind_handler.hpp>
#include <boost/beast/core/buffer_traits.hpp>
#include <boost/make_shared.hpp>
#include <stdexcept>

View File

@@ -11,7 +11,6 @@
#define BOOST_BEAST_TEST_STREAM_HPP
#include <boost/beast/core/detail/config.hpp>
#include <boost/beast/core/bind_handler.hpp>
#include <boost/beast/core/flat_buffer.hpp>
#include <boost/beast/core/role.hpp>
#include <boost/beast/core/string.hpp>

View File

@@ -11,7 +11,6 @@
#define BOOST_BEAST_CORE_ASYNC_BASE_HPP
#include <boost/beast/core/detail/config.hpp>
#include <boost/beast/core/bind_handler.hpp>
#include <boost/beast/core/detail/allocator.hpp>
#include <boost/beast/core/detail/async_base.hpp>
#include <boost/beast/core/detail/filtering_cancellation_slot.hpp>
@@ -24,6 +23,7 @@
#include <boost/asio/handler_continuation_hook.hpp>
#include <boost/asio/dispatch.hpp>
#include <boost/asio/post.hpp>
#include <boost/asio/prepend.hpp>
#include <boost/core/exchange.hpp>
#include <boost/core/empty_value.hpp>
#include <utility>
@@ -425,9 +425,7 @@ public:
auto const ex = this->get_immediate_executor();
net::dispatch(
ex,
beast::bind_front_handler(
std::move(h_),
std::forward<Args>(args)...));
net::prepend(std::move(h_), std::forward<Args>(args)...));
wg1_.reset();
}
else

View File

@@ -10,7 +10,6 @@
#ifndef BOOST_BEAST_DETAIL_IMPL_READ_HPP
#define BOOST_BEAST_DETAIL_IMPL_READ_HPP
#include <boost/beast/core/bind_handler.hpp>
#include <boost/beast/core/async_base.hpp>
#include <boost/beast/core/flat_static_buffer.hpp>
#include <boost/beast/core/read_size.hpp>

View File

@@ -11,12 +11,12 @@
#define BOOST_BEAST_IMPL_BUFFERED_READ_STREAM_HPP
#include <boost/beast/core/async_base.hpp>
#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/detail/is_invocable.hpp>
#include <boost/asio/dispatch.hpp>
#include <boost/asio/prepend.hpp>
#include <boost/throw_exception.hpp>
namespace boost {
@@ -84,8 +84,7 @@ public:
const auto ex = this->get_immediate_executor();
return net::dispatch(
ex,
beast::bind_front_handler(
std::move(*this), ec, 0));
net::prepend(std::move(*this), ec, 0));
}
case 1:
// upcall

View File

@@ -13,7 +13,6 @@
#if BOOST_BEAST_USE_WIN32_FILE
#include <boost/beast/core/async_base.hpp>
#include <boost/beast/core/bind_handler.hpp>
#include <boost/beast/core/buffers_range.hpp>
#include <boost/beast/core/detail/clamp.hpp>
#include <boost/beast/core/detail/is_invocable.hpp>

View File

@@ -22,6 +22,7 @@
#include <boost/asio/error.hpp>
#include <boost/asio/compose.hpp>
#include <boost/asio/coroutine.hpp>
#include <boost/asio/prepend.hpp>
namespace boost {
namespace beast {
@@ -249,9 +250,7 @@ public:
asio::get_associated_immediate_executor(
self, s_.get_executor());
net::dispatch(
ex,
beast::bind_front_handler(std::move(self), ec));
net::dispatch(ex, net::prepend(std::move(self), ec));
}
}
self.complete(ec, bytes_transferred_);

View File

@@ -12,7 +12,6 @@
#include <boost/beast/http/type_traits.hpp>
#include <boost/beast/core/async_base.hpp>
#include <boost/beast/core/bind_handler.hpp>
#include <boost/beast/core/buffers_range.hpp>
#include <boost/beast/core/make_printable.hpp>
#include <boost/beast/core/stream_traits.hpp>
@@ -20,6 +19,7 @@
#include <boost/asio/coroutine.hpp>
#include <boost/asio/dispatch.hpp>
#include <boost/asio/write.hpp>
#include <boost/asio/prepend.hpp>
#include <boost/optional.hpp>
#include <boost/throw_exception.hpp>
#include <ostream>
@@ -102,11 +102,8 @@ public:
__FILE__, __LINE__,
"http::async_write_some"));
auto ex = asio::get_associated_immediate_executor(*this, s_.get_executor());
return net::dispatch(
ex,
beast::bind_front_handler(
std::move(*this), ec, 0));
const auto ex = asio::get_associated_immediate_executor(*this, s_.get_executor());
return net::dispatch(ex, net::prepend(std::move(*this), ec, 0));
}
if(f.invoked)
{
@@ -122,10 +119,7 @@ public:
"http::async_write_some"));
const auto ex = this->get_immediate_executor();
return net::dispatch(
ex,
beast::bind_front_handler(
std::move(*this), ec, 0));
return net::dispatch(ex, net::prepend(std::move(*this), ec, 0));
}
void

View File

@@ -11,7 +11,6 @@
#define BOOST_BEAST_WEBSOCKET_IMPL_PING_HPP
#include <boost/beast/core/async_base.hpp>
#include <boost/beast/core/bind_handler.hpp>
#include <boost/beast/core/stream_traits.hpp>
#include <boost/beast/core/detail/bind_continuation.hpp>
#include <boost/beast/websocket/detail/frame.hpp>

View File

@@ -15,7 +15,6 @@
#include <boost/beast/websocket/detail/mask.hpp>
#include <boost/beast/websocket/impl/stream_impl.hpp>
#include <boost/beast/core/async_base.hpp>
#include <boost/beast/core/bind_handler.hpp>
#include <boost/beast/core/buffers_prefix.hpp>
#include <boost/beast/core/buffers_suffix.hpp>
#include <boost/beast/core/flat_static_buffer.hpp>

View File

@@ -11,12 +11,12 @@
#define BOOST_BEAST_WEBSOCKET_IMPL_TEARDOWN_HPP
#include <boost/beast/core/async_base.hpp>
#include <boost/beast/core/bind_handler.hpp>
#include <boost/beast/core/stream_traits.hpp>
#include <boost/beast/core/detail/bind_continuation.hpp>
#include <boost/beast/core/detail/is_invocable.hpp>
#include <boost/asio/coroutine.hpp>
#include <boost/asio/dispatch.hpp>
#include <boost/asio/prepend.hpp>
#include <memory>
namespace boost {
@@ -129,8 +129,7 @@ public:
));
const auto ex = this->get_immediate_executor();
net::dispatch(ex, bind_front_handler(
std::move(*this), ec));
net::dispatch(ex, net::prepend(std::move(*this), ec));
}
}
{

View File

@@ -12,7 +12,6 @@
#include <boost/beast/websocket/detail/mask.hpp>
#include <boost/beast/core/async_base.hpp>
#include <boost/beast/core/bind_handler.hpp>
#include <boost/beast/core/buffer_traits.hpp>
#include <boost/beast/core/buffers_cat.hpp>
#include <boost/beast/core/buffers_prefix.hpp>

View File

@@ -13,6 +13,7 @@
#include "stream_tests.hpp"
#include <boost/beast/_experimental/unit_test/suite.hpp>
#include <boost/beast/core/bind_handler.hpp>
#include <boost/beast/core/flat_buffer.hpp>
#include <boost/beast/core/stream_traits.hpp>
#include <boost/beast/core/string.hpp>