beast support default completion & rebind.

buffers_generator uses default_completion.
websocket::stream has a rebinding constructor.
ssl_stream has a rebind_executor member.
basic_stream has rebinding constructor.
This commit is contained in:
Klemens Morgenstern
2022-10-30 00:13:54 +08:00
committed by Klemens Morgenstern
parent d3b82a2fb0
commit 1fc340713c
9 changed files with 112 additions and 43 deletions
+5 -10
View File
@@ -23,6 +23,7 @@
#include <boost/beast/http/string_body.hpp>
#include <boost/beast/http/write.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/detached.hpp>
#include <boost/asio/spawn.hpp>
#include <boost/asio/strand.hpp>
#include <boost/asio/write.hpp>
@@ -551,13 +552,10 @@ public:
// stream destroyed
test_server srv("", ep, log);
{
stream_type s(ioc);
auto s = net::detached.as_default_on(stream_type(ioc));
s.socket().connect(srv.local_endpoint());
s.expires_after(std::chrono::seconds(0));
s.async_read_some(mb,
[](error_code, std::size_t)
{
});
s.async_read_some(mb);
}
ioc.run();
ioc.restart();
@@ -566,12 +564,9 @@ public:
{
// stale timer
test_acceptor a;
stream_type s(ioc);
auto s = net::detached.as_default_on(stream_type(ioc));
s.expires_after(std::chrono::milliseconds(50));
s.async_read_some(mb,
[](error_code, std::size_t)
{
});
s.async_read_some(mb);
std::this_thread::sleep_for(
std::chrono::milliseconds(100));
ioc.run();