Update for Net-TS Asio (API Change):

fix #769

The following classes are removed:

* handler_type
* async_result
* async_completion
* is_dynamic_buffer
* is_const_buffer_sequence
* is_mutable_buffer_sequence
* handler_alloc

Actions Required:

* Use BOOST_ASIO_HANDLER_TYPE instead of handler_type
* Use BOOST_ASIO_INITFN_RESULT_TYPE instead of async_result
* Use boost::asio::async_completion
* Use boost::asio::is_dynamic_buffer
* Use boost::asio::is_const_buffer_sequence
* Use boost::asio::is_mutable_buffer_sequence
* boost::asio::associated_allocator_t replaces handler_alloc
This commit is contained in:
Vinnie Falco committed 2017-10-23 17:11:27 -07:00
1 parent 9dc9ca13b9
commit 3a28e999af
173 files changed
+3214 -4138

No files matched your search

+5 -7
View File
@@ -67,15 +67,13 @@ public:
fill(MutableBufferSequence const& buffers)
{
std::size_t n = 0;
using boost::asio::buffer_cast;
using boost::asio::buffer_size;
for(boost::asio::mutable_buffer buffer : buffers)
for(auto b : beast::detail::buffers_range(buffers))
{
std::fill(
buffer_cast<char*>(buffer),
buffer_cast<char*>(buffer) +
buffer_size(buffer), '\0');
n += buffer_size(buffer);
reinterpret_cast<char*>(b.data()),
reinterpret_cast<char*>(b.data()) +
b.size(), '\0');
n += b.size();
}
return n;
}
+4 -6
View File
@@ -42,13 +42,11 @@ public:
std::string
to_string(ConstBufferSequence const& bs)
{
using boost::asio::buffer_cast;
using boost::asio::buffer_size;
std::string s;
s.reserve(buffer_size(bs));
for(boost::asio::const_buffer b : bs)
s.append(buffer_cast<char const*>(b),
buffer_size(b));
for(auto b : beast::detail::buffers_range(bs))
s.append(reinterpret_cast<char const*>(b.data()),
b.size());
return s;
}
@@ -172,7 +170,7 @@ public:
isRequest, bench_parser<isRequest, Body, Fields>>
{
using mutable_buffers_type =
boost::asio::mutable_buffers_1;
boost::asio::mutable_buffer;
void
on_request_impl(verb, string_view,
+4 -6
View File
@@ -264,17 +264,15 @@ std::size_t
nodejs_basic_parser<Derived>::write(
ConstBufferSequence const& buffers, error_code& ec)
{
static_assert(beast::is_const_buffer_sequence<
static_assert(boost::asio::is_const_buffer_sequence<
ConstBufferSequence>::value,
"ConstBufferSequence requirements not met");
using boost::asio::buffer_cast;
using boost::asio::buffer_size;
std::size_t bytes_used = 0;
for(boost::asio::const_buffer buffer : buffers)
for(auto buffer : beast::detail::buffers_range(buffers))
{
auto const n = write(
buffer_cast<void const*>(buffer),
buffer_size(buffer), ec);
reinterpret_cast<void const*>(buffer.data()),
buffer.size(), ec);
if(ec)
return 0;
bytes_used += n;
+30 -11
View File
@@ -39,19 +39,37 @@ namespace ws = boost::beast::websocket;
namespace ph = std::placeholders;
using error_code = boost::beast::error_code;
class test_buffer : public asio::const_buffers_1
class test_buffer
{
char data_[4096];
boost::asio::const_buffer b_;
public:
using const_iterator =
boost::asio::const_buffer const*;
using value_type = boost::asio::const_buffer;
test_buffer()
: asio::const_buffers_1(data_, sizeof(data_))
: b_(data_, sizeof(data_))
{
std::mt19937_64 rng;
std::uniform_int_distribution<unsigned short> dist;
for(auto& c : data_)
c = static_cast<unsigned char>(dist(rng));
}
const_iterator
begin() const
{
return &b_;
}
const_iterator
end() const
{
return begin() + 1;
}
};
class report
@@ -96,7 +114,8 @@ class connection
std::size_t messages_;
report& rep_;
test_buffer const& tb_;
asio::io_service::strand strand_;
asio::strand<
asio::io_context::executor_type> strand_;
boost::beast::multi_buffer buffer_;
std::mt19937_64 rng_;
std::size_t count_ = 0;
@@ -105,18 +124,18 @@ class connection
public:
connection(
asio::io_service& ios,
asio::io_context& ioc,
tcp::endpoint const& ep,
std::size_t messages,
bool deflate,
report& rep,
test_buffer const& tb)
: ws_(ios)
: ws_(ioc)
, ep_(ep)
, messages_(messages)
, rep_(rep)
, tb_(tb)
, strand_(ios)
, strand_(ioc.get_executor())
{
ws::permessage_deflate pmd;
pmd.client_enable = deflate;
@@ -274,7 +293,7 @@ main(int argc, char** argv)
return EXIT_FAILURE;
}
auto const address = ip::address::from_string(argv[1]);
auto const address = boost::asio::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]));
@@ -286,12 +305,12 @@ main(int argc, char** argv)
for(auto i = trials; i != 0; --i)
{
report rep;
boost::asio::io_service ios{1};
boost::asio::io_context ioc{1};
for(auto j = workers; j; --j)
{
auto sp =
std::make_shared<connection>(
ios,
ioc,
tcp::endpoint{address, port},
work,
deflate,
@@ -304,9 +323,9 @@ main(int argc, char** argv)
if(threads > 1)
{
tv.reserve(threads);
tv.emplace_back([&ios]{ ios.run(); });
tv.emplace_back([&ioc]{ ioc.run(); });
}
ios.run();
ioc.run();
for(auto& t : tv)
t.join();
auto const elapsed = clock.elapsed();