forked from boostorg/beast
net is a namespace alias for boost::asio:
The namespace alias beast::net replaces boost::asio in all code and documentation.
This commit is contained in:
1 parent
a5739c3ea0
commit
f995fd41a3
185 files changed
+2486
-2392
No files matched your search
@@ -224,10 +224,10 @@ public:
|
||||
,[&](){ return do_hints <flat_buffer>(repeat, count, size); }
|
||||
,[&](){ return do_random <flat_buffer>(repeat, count, size); }
|
||||
);
|
||||
do_trials("boost::asio::streambuf", trials,
|
||||
[&](){ return do_prepares<boost::asio::streambuf>(repeat, count, size); }
|
||||
,[&](){ return do_hints <boost::asio::streambuf>(repeat, count, size); }
|
||||
,[&](){ return do_random <boost::asio::streambuf>(repeat, count, size); }
|
||||
do_trials("net::streambuf", trials,
|
||||
[&](){ return do_prepares<net::streambuf>(repeat, count, size); }
|
||||
,[&](){ return do_hints <net::streambuf>(repeat, count, size); }
|
||||
,[&](){ return do_random <net::streambuf>(repeat, count, size); }
|
||||
);
|
||||
log << std::endl;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
basic_parser<isRequest, Derived>& parser,
|
||||
error_code& ec)
|
||||
{
|
||||
using boost::asio::buffer_size;
|
||||
using net::buffer_size;
|
||||
beast::buffers_suffix<
|
||||
ConstBufferSequence> cb{buffers};
|
||||
std::size_t used = 0;
|
||||
@@ -158,7 +158,7 @@ public:
|
||||
isRequest, bench_parser<isRequest, Body, Fields>>
|
||||
{
|
||||
using mutable_buffers_type =
|
||||
boost::asio::mutable_buffer;
|
||||
net::mutable_buffer;
|
||||
|
||||
void
|
||||
on_request_impl(verb, string_view,
|
||||
|
||||
@@ -265,7 +265,7 @@ std::size_t
|
||||
nodejs_basic_parser<Derived>::write(
|
||||
ConstBufferSequence const& buffers, error_code& ec)
|
||||
{
|
||||
static_assert(boost::asio::is_const_buffer_sequence<
|
||||
static_assert(net::is_const_buffer_sequence<
|
||||
ConstBufferSequence>::value,
|
||||
"ConstBufferSequence requirements not met");
|
||||
std::size_t bytes_used = 0;
|
||||
|
||||
@@ -32,23 +32,22 @@
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
namespace asio = boost::asio;
|
||||
namespace ip = boost::asio::ip;
|
||||
using tcp = boost::asio::ip::tcp;
|
||||
namespace ws = boost::beast::websocket;
|
||||
namespace ph = std::placeholders;
|
||||
using error_code = boost::beast::error_code;
|
||||
namespace beast = boost::beast; // from <boost/beast.hpp>
|
||||
namespace http = beast::http; // from <boost/beast/http.hpp>
|
||||
namespace websocket = beast::websocket; // from <boost/beast/websocket.hpp>
|
||||
namespace net = boost::asio; // from <boost/asio.hpp>
|
||||
using tcp = boost::asio::ip::tcp; // from <boost/asio/ip/tcp.hpp>
|
||||
|
||||
class test_buffer
|
||||
{
|
||||
char data_[4096];
|
||||
boost::asio::const_buffer b_;
|
||||
net::const_buffer b_;
|
||||
|
||||
public:
|
||||
using const_iterator =
|
||||
boost::asio::const_buffer const*;
|
||||
net::const_buffer const*;
|
||||
|
||||
using value_type = boost::asio::const_buffer;
|
||||
using value_type = net::const_buffer;
|
||||
|
||||
test_buffer()
|
||||
: b_(data_, sizeof(data_))
|
||||
@@ -101,7 +100,7 @@ public:
|
||||
};
|
||||
|
||||
void
|
||||
fail(boost::system::error_code ec, char const* what)
|
||||
fail(beast::error_code ec, char const* what)
|
||||
{
|
||||
std::cerr << what << ": " << ec.message() << "\n";
|
||||
}
|
||||
@@ -109,13 +108,13 @@ fail(boost::system::error_code ec, char const* what)
|
||||
class connection
|
||||
: public std::enable_shared_from_this<connection>
|
||||
{
|
||||
ws::stream<tcp::socket> ws_;
|
||||
websocket::stream<tcp::socket> ws_;
|
||||
tcp::endpoint ep_;
|
||||
std::size_t messages_;
|
||||
report& rep_;
|
||||
test_buffer const& tb_;
|
||||
asio::strand<
|
||||
asio::io_context::executor_type> strand_;
|
||||
net::strand<
|
||||
net::io_context::executor_type> strand_;
|
||||
boost::beast::multi_buffer buffer_;
|
||||
std::mt19937_64 rng_;
|
||||
std::size_t count_ = 0;
|
||||
@@ -124,7 +123,7 @@ class connection
|
||||
|
||||
public:
|
||||
connection(
|
||||
asio::io_context& ioc,
|
||||
net::io_context& ioc,
|
||||
tcp::endpoint const& ep,
|
||||
std::size_t messages,
|
||||
bool deflate,
|
||||
@@ -137,7 +136,7 @@ public:
|
||||
, tb_(tb)
|
||||
, strand_(ioc.get_executor())
|
||||
{
|
||||
ws::permessage_deflate pmd;
|
||||
websocket::permessage_deflate pmd;
|
||||
pmd.client_enable = deflate;
|
||||
ws_.set_option(pmd);
|
||||
ws_.binary(true);
|
||||
@@ -157,12 +156,12 @@ public:
|
||||
alloc_.wrap(std::bind(
|
||||
&connection::on_connect,
|
||||
shared_from_this(),
|
||||
ph::_1)));
|
||||
std::placeholders::_1)));
|
||||
}
|
||||
|
||||
private:
|
||||
void
|
||||
on_connect(error_code ec)
|
||||
on_connect(beast::error_code ec)
|
||||
{
|
||||
if(ec)
|
||||
return fail(ec, "on_connect");
|
||||
@@ -173,11 +172,11 @@ private:
|
||||
alloc_.wrap(std::bind(
|
||||
&connection::on_handshake,
|
||||
shared_from_this(),
|
||||
ph::_1)));
|
||||
std::placeholders::_1)));
|
||||
}
|
||||
|
||||
void
|
||||
on_handshake(error_code ec)
|
||||
on_handshake(beast::error_code ec)
|
||||
{
|
||||
if(ec)
|
||||
return fail(ec, "handshake");
|
||||
@@ -189,17 +188,17 @@ private:
|
||||
do_write()
|
||||
{
|
||||
std::geometric_distribution<std::size_t> dist{
|
||||
double(4) / boost::asio::buffer_size(tb_)};
|
||||
double(4) / net::buffer_size(tb_)};
|
||||
ws_.async_write_some(true,
|
||||
boost::beast::buffers_prefix(dist(rng_), tb_),
|
||||
alloc_.wrap(std::bind(
|
||||
&connection::on_write,
|
||||
shared_from_this(),
|
||||
ph::_1)));
|
||||
std::placeholders::_1)));
|
||||
}
|
||||
|
||||
void
|
||||
on_write(error_code ec)
|
||||
on_write(beast::error_code ec)
|
||||
{
|
||||
if(ec)
|
||||
return fail(ec, "write");
|
||||
@@ -211,7 +210,7 @@ private:
|
||||
alloc_.wrap(std::bind(
|
||||
&connection::on_close,
|
||||
shared_from_this(),
|
||||
ph::_1)));
|
||||
std::placeholders::_1)));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -221,11 +220,11 @@ private:
|
||||
alloc_.wrap(std::bind(
|
||||
&connection::on_read,
|
||||
shared_from_this(),
|
||||
ph::_1)));
|
||||
std::placeholders::_1)));
|
||||
}
|
||||
|
||||
void
|
||||
on_read(error_code ec)
|
||||
on_read(beast::error_code ec)
|
||||
{
|
||||
if(ec)
|
||||
return fail(ec, "read");
|
||||
@@ -237,7 +236,7 @@ private:
|
||||
}
|
||||
|
||||
void
|
||||
on_close(error_code ec)
|
||||
on_close(beast::error_code ec)
|
||||
{
|
||||
if(ec)
|
||||
return fail(ec, "close");
|
||||
@@ -293,7 +292,7 @@ main(int argc, char** argv)
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
auto const address = boost::asio::ip::make_address(argv[1]);
|
||||
auto const address = net::ip::make_address(argv[1]);
|
||||
auto const port = static_cast<unsigned short>(std::atoi(argv[2]));
|
||||
auto const trials = static_cast<std::size_t>(std::atoi(argv[3]));
|
||||
auto const messages= static_cast<std::size_t>(std::atoi(argv[4]));
|
||||
@@ -305,7 +304,7 @@ main(int argc, char** argv)
|
||||
for(auto i = trials; i != 0; --i)
|
||||
{
|
||||
report rep;
|
||||
boost::asio::io_context ioc{1};
|
||||
net::io_context ioc{1};
|
||||
for(auto j = workers; j; --j)
|
||||
{
|
||||
auto sp =
|
||||
|
||||
Reference in new issue
Block a user