mirror of
https://github.com/boostorg/beast.git
synced 2025-07-31 21:34:46 +02:00
make_strand is in net::
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
Version 226:
|
||||
|
||||
* Support -fno-exceptions
|
||||
* make_strand is in net::
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
@@ -90,8 +90,8 @@ Alternatively, we can construct the stream from an executor:
|
||||
[code_core_3_timeouts_2]
|
||||
|
||||
The function
|
||||
[link beast.ref.boost__beast__make_strand `make_strand`] returns a strand
|
||||
constructed from an execution context or executor. When a
|
||||
[@boost:/doc/html/boost_asio/reference/make_strand.html `make_strand`]
|
||||
returns a strand constructed from an execution context or executor. When a
|
||||
[@boost:/doc/html/boost_asio/reference/strand.html `net::strand`]
|
||||
is chosen for the stream's executor, all completion handlers which do not
|
||||
already have an associated executor will use the strand. This is both a
|
||||
|
@@ -74,7 +74,6 @@
|
||||
<member><link linkend="beast.ref.boost__beast__generic_category">generic_category</link></member>
|
||||
<member><link linkend="beast.ref.boost__beast__get_lowest_layer">get_lowest_layer</link> <emphasis role="green">★</emphasis></member>
|
||||
<member><link linkend="beast.ref.boost__beast__iequals">iequals</link></member>
|
||||
<member><link linkend="beast.ref.boost__beast__make_strand">make_strand</link> <emphasis role="green">★</emphasis></member>
|
||||
<member><link linkend="beast.ref.boost__beast__to_static_string">to_static_string</link></member>
|
||||
</simplelist>
|
||||
</entry>
|
||||
|
@@ -117,8 +117,6 @@
|
||||
* Add `cdata()` to also return constant readable bytes
|
||||
* Eligible member functions are declared `noexcept`
|
||||
|
||||
* New `make_strand`
|
||||
|
||||
* ([issue 1345]) Better
|
||||
`flat_buffer`,
|
||||
`multi_buffer`
|
||||
|
@@ -874,7 +874,7 @@ public:
|
||||
std::shared_ptr<std::string const> const& doc_root)
|
||||
: ioc_(ioc)
|
||||
, ctx_(ctx)
|
||||
, acceptor_(beast::make_strand(ioc))
|
||||
, acceptor_(net::make_strand(ioc))
|
||||
, doc_root_(doc_root)
|
||||
{
|
||||
beast::error_code ec;
|
||||
@@ -927,7 +927,7 @@ public:
|
||||
{
|
||||
// The new connection gets its own strand
|
||||
acceptor_.async_accept(
|
||||
beast::make_strand(ioc_),
|
||||
net::make_strand(ioc_),
|
||||
beast::bind_front_handler(
|
||||
&listener::on_accept,
|
||||
shared_from_this()));
|
||||
|
@@ -545,7 +545,7 @@ public:
|
||||
tcp::endpoint endpoint,
|
||||
std::shared_ptr<std::string const> const& doc_root)
|
||||
: ioc_(ioc)
|
||||
, acceptor_(beast::make_strand(ioc))
|
||||
, acceptor_(net::make_strand(ioc))
|
||||
, doc_root_(doc_root)
|
||||
{
|
||||
beast::error_code ec;
|
||||
@@ -598,7 +598,7 @@ public:
|
||||
{
|
||||
// The new connection gets its own strand
|
||||
acceptor_.async_accept(
|
||||
beast::make_strand(ioc_),
|
||||
net::make_strand(ioc_),
|
||||
beast::bind_front_handler(
|
||||
&listener::on_accept,
|
||||
shared_from_this()));
|
||||
|
@@ -19,6 +19,7 @@
|
||||
#include <boost/beast/http.hpp>
|
||||
#include <boost/beast/ssl.hpp>
|
||||
#include <boost/beast/version.hpp>
|
||||
#include <boost/asio/strand.hpp>
|
||||
#include <cstdlib>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
@@ -54,8 +55,8 @@ public:
|
||||
// ensure that handlers do not execute concurrently.
|
||||
explicit
|
||||
session(net::io_context& ioc, ssl::context& ctx)
|
||||
: resolver_(beast::make_strand(ioc))
|
||||
, stream_(beast::make_strand(ioc), ctx)
|
||||
: resolver_(net::make_strand(ioc))
|
||||
, stream_(net::make_strand(ioc), ctx)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -16,6 +16,7 @@
|
||||
#include <boost/beast/core.hpp>
|
||||
#include <boost/beast/http.hpp>
|
||||
#include <boost/beast/version.hpp>
|
||||
#include <boost/asio/strand.hpp>
|
||||
#include <cstdlib>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
@@ -50,8 +51,8 @@ public:
|
||||
// ensure that handlers do not execute concurrently.
|
||||
explicit
|
||||
session(net::io_context& ioc)
|
||||
: resolver_(beast::make_strand(ioc))
|
||||
, stream_(beast::make_strand(ioc))
|
||||
: resolver_(net::make_strand(ioc))
|
||||
, stream_(net::make_strand(ioc))
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -164,8 +164,8 @@ public:
|
||||
crawl_report& report,
|
||||
net::io_context& ioc)
|
||||
: report_(report)
|
||||
, resolver_(beast::make_strand(ioc))
|
||||
, stream_(beast::make_strand(ioc))
|
||||
, resolver_(net::make_strand(ioc))
|
||||
, stream_(net::make_strand(ioc))
|
||||
{
|
||||
// Set up the common fields of the request
|
||||
req_.version(11);
|
||||
|
@@ -473,7 +473,7 @@ public:
|
||||
{
|
||||
// The new connection gets its own strand
|
||||
acceptor_.async_accept(
|
||||
beast::make_strand(ioc_),
|
||||
net::make_strand(ioc_),
|
||||
beast::bind_front_handler(
|
||||
&listener::on_accept,
|
||||
shared_from_this()));
|
||||
|
@@ -362,7 +362,7 @@ public:
|
||||
tcp::endpoint endpoint,
|
||||
std::shared_ptr<std::string const> const& doc_root)
|
||||
: ioc_(ioc)
|
||||
, acceptor_(beast::make_strand(ioc))
|
||||
, acceptor_(net::make_strand(ioc))
|
||||
, doc_root_(doc_root)
|
||||
{
|
||||
beast::error_code ec;
|
||||
@@ -415,7 +415,7 @@ public:
|
||||
{
|
||||
// The new connection gets its own strand
|
||||
acceptor_.async_accept(
|
||||
beast::make_strand(ioc_),
|
||||
net::make_strand(ioc_),
|
||||
beast::bind_front_handler(
|
||||
&listener::on_accept,
|
||||
shared_from_this()));
|
||||
|
@@ -570,7 +570,7 @@ public:
|
||||
std::shared_ptr<std::string const> const& doc_root)
|
||||
: ioc_(ioc)
|
||||
, ctx_(ctx)
|
||||
, acceptor_(beast::make_strand(ioc))
|
||||
, acceptor_(net::make_strand(ioc))
|
||||
, doc_root_(doc_root)
|
||||
{
|
||||
beast::error_code ec;
|
||||
@@ -623,7 +623,7 @@ public:
|
||||
{
|
||||
// The new connection gets its own strand
|
||||
acceptor_.async_accept(
|
||||
beast::make_strand(ioc_),
|
||||
net::make_strand(ioc_),
|
||||
beast::bind_front_handler(
|
||||
&listener::on_accept,
|
||||
shared_from_this()));
|
||||
|
@@ -413,8 +413,8 @@ public:
|
||||
std::shared_ptr<std::string const> const& doc_root)
|
||||
: ioc_(ioc)
|
||||
, ctx_(ctx)
|
||||
, acceptor_(beast::make_strand(ioc))
|
||||
, socket_(beast::make_strand(ioc))
|
||||
, acceptor_(net::make_strand(ioc))
|
||||
, socket_(net::make_strand(ioc))
|
||||
, doc_root_(doc_root)
|
||||
{
|
||||
beast::error_code ec;
|
||||
@@ -490,7 +490,7 @@ public:
|
||||
}
|
||||
|
||||
// Make sure each session gets its own strand
|
||||
socket_ = tcp::socket(beast::make_strand(ioc_));
|
||||
socket_ = tcp::socket(net::make_strand(ioc_));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -356,8 +356,8 @@ public:
|
||||
tcp::endpoint endpoint,
|
||||
std::shared_ptr<std::string const> const& doc_root)
|
||||
: ioc_(ioc)
|
||||
, acceptor_(beast::make_strand(ioc))
|
||||
, socket_(beast::make_strand(ioc))
|
||||
, acceptor_(net::make_strand(ioc))
|
||||
, socket_(net::make_strand(ioc))
|
||||
, doc_root_(doc_root)
|
||||
{
|
||||
beast::error_code ec;
|
||||
@@ -430,7 +430,7 @@ public:
|
||||
}
|
||||
|
||||
// Make sure each session gets its own strand
|
||||
socket_ = tcp::socket(beast::make_strand(ioc_));
|
||||
socket_ = tcp::socket(net::make_strand(ioc_));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -19,6 +19,7 @@
|
||||
#include <boost/beast/ssl.hpp>
|
||||
#include <boost/beast/websocket.hpp>
|
||||
#include <boost/beast/websocket/ssl.hpp>
|
||||
#include <boost/asio/strand.hpp>
|
||||
#include <cstdlib>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
@@ -55,8 +56,8 @@ public:
|
||||
// Resolver and socket require an io_context
|
||||
explicit
|
||||
session(net::io_context& ioc, ssl::context& ctx)
|
||||
: resolver_(beast::make_strand(ioc))
|
||||
, ws_(beast::make_strand(ioc), ctx)
|
||||
: resolver_(net::make_strand(ioc))
|
||||
, ws_(net::make_strand(ioc), ctx)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -15,6 +15,7 @@
|
||||
|
||||
#include <boost/beast/core.hpp>
|
||||
#include <boost/beast/websocket.hpp>
|
||||
#include <boost/asio/strand.hpp>
|
||||
#include <cstdlib>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
@@ -49,8 +50,8 @@ public:
|
||||
// Resolver and socket require an io_context
|
||||
explicit
|
||||
session(net::io_context& ioc)
|
||||
: resolver_(beast::make_strand(ioc))
|
||||
, ws_(beast::make_strand(ioc))
|
||||
: resolver_(net::make_strand(ioc))
|
||||
, ws_(net::make_strand(ioc))
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -183,7 +183,7 @@ public:
|
||||
tcp::endpoint endpoint)
|
||||
: ioc_(ioc)
|
||||
, ctx_(ctx)
|
||||
, acceptor_(beast::make_strand(ioc))
|
||||
, acceptor_(net::make_strand(ioc))
|
||||
{
|
||||
beast::error_code ec;
|
||||
|
||||
@@ -235,7 +235,7 @@ public:
|
||||
{
|
||||
// The new connection gets its own strand
|
||||
acceptor_.async_accept(
|
||||
beast::make_strand(ioc_),
|
||||
net::make_strand(ioc_),
|
||||
beast::bind_front_handler(
|
||||
&listener::on_accept,
|
||||
shared_from_this()));
|
||||
|
@@ -206,7 +206,7 @@ public:
|
||||
{
|
||||
// The new connection gets its own strand
|
||||
acceptor_.async_accept(
|
||||
beast::make_strand(ioc_),
|
||||
net::make_strand(ioc_),
|
||||
beast::bind_front_handler(
|
||||
&listener::on_accept,
|
||||
shared_from_this()));
|
||||
|
@@ -62,7 +62,7 @@ run()
|
||||
{
|
||||
// The new connection gets its own strand
|
||||
acceptor_.async_accept(
|
||||
beast::make_strand(ioc_),
|
||||
net::make_strand(ioc_),
|
||||
beast::bind_front_handler(
|
||||
&listener::on_accept,
|
||||
shared_from_this()));
|
||||
@@ -94,7 +94,7 @@ on_accept(beast::error_code ec, tcp::socket socket)
|
||||
|
||||
// The new connection gets its own strand
|
||||
acceptor_.async_accept(
|
||||
beast::make_strand(ioc_),
|
||||
net::make_strand(ioc_),
|
||||
beast::bind_front_handler(
|
||||
&listener::on_accept,
|
||||
shared_from_this()));
|
||||
|
@@ -249,7 +249,7 @@ public:
|
||||
net::io_context& ioc,
|
||||
tcp::endpoint endpoint)
|
||||
: ioc_(ioc)
|
||||
, acceptor_(beast::make_strand(ioc))
|
||||
, acceptor_(net::make_strand(ioc))
|
||||
{
|
||||
beast::error_code ec;
|
||||
|
||||
@@ -301,7 +301,7 @@ public:
|
||||
{
|
||||
// The new connection gets its own strand
|
||||
acceptor_.async_accept(
|
||||
beast::make_strand(ioc_),
|
||||
net::make_strand(ioc_),
|
||||
beast::bind_front_handler(
|
||||
&async_listener::on_accept,
|
||||
shared_from_this()));
|
||||
|
@@ -250,7 +250,7 @@ public:
|
||||
}
|
||||
|
||||
// Make sure each session gets its own strand
|
||||
socket_ = tcp::socket(beast::make_strand(ioc_));
|
||||
socket_ = tcp::socket(net::make_strand(ioc_));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -151,8 +151,8 @@ public:
|
||||
net::io_context& ioc,
|
||||
tcp::endpoint endpoint)
|
||||
: ioc_(ioc)
|
||||
, acceptor_(beast::make_strand(ioc))
|
||||
, socket_(beast::make_strand(ioc))
|
||||
, acceptor_(net::make_strand(ioc))
|
||||
, socket_(net::make_strand(ioc))
|
||||
{
|
||||
beast::error_code ec;
|
||||
|
||||
@@ -224,7 +224,7 @@ public:
|
||||
}
|
||||
|
||||
// Make sure each session gets its own strand
|
||||
socket_ = tcp::socket(beast::make_strand(ioc_));
|
||||
socket_ = tcp::socket(net::make_strand(ioc_));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -36,7 +36,6 @@
|
||||
#include <boost/beast/core/flat_stream.hpp>
|
||||
#include <boost/beast/core/handler_ptr.hpp>
|
||||
#include <boost/beast/core/make_printable.hpp>
|
||||
#include <boost/beast/core/make_strand.hpp>
|
||||
#include <boost/beast/core/multi_buffer.hpp>
|
||||
#include <boost/beast/core/ostream.hpp>
|
||||
#include <boost/beast/core/rate_policy.hpp>
|
||||
|
@@ -1,60 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// Official repository: https://github.com/boostorg/beast
|
||||
//
|
||||
|
||||
#ifndef BOOST_BEAST_MAKE_STRAND_HPP
|
||||
#define BOOST_BEAST_MAKE_STRAND_HPP
|
||||
|
||||
#include <boost/beast/core/detail/config.hpp>
|
||||
#include <boost/beast/core/stream_traits.hpp>
|
||||
#include <boost/asio/is_executor.hpp>
|
||||
#include <boost/asio/strand.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
||||
/** Return a strand usable with the specified execution context.
|
||||
*/
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
template<class ExecutionContext>
|
||||
__see_below__
|
||||
#else
|
||||
template<class ExecutionContext
|
||||
,class = typename std::enable_if<
|
||||
has_get_executor<ExecutionContext>::value &&
|
||||
std::is_convertible<
|
||||
ExecutionContext&,
|
||||
net::execution_context&>::value>::type
|
||||
>
|
||||
net::strand<executor_type<ExecutionContext>>
|
||||
#endif
|
||||
make_strand(ExecutionContext& context)
|
||||
{
|
||||
return net::strand<executor_type<
|
||||
ExecutionContext>>{context.get_executor()};
|
||||
}
|
||||
|
||||
/** Return a strand usable with the specified executor.
|
||||
*/
|
||||
template<class Executor
|
||||
#if ! BOOST_BEAST_DOXYGEN
|
||||
, class = typename
|
||||
net::is_executor<Executor>::type
|
||||
#endif
|
||||
>
|
||||
net::strand<Executor>
|
||||
make_strand(Executor const& ex)
|
||||
{
|
||||
return net::strand<Executor>{ex};
|
||||
}
|
||||
|
||||
} // beast
|
||||
} // boost
|
||||
|
||||
#endif
|
@@ -57,7 +57,6 @@ add_executable (tests-beast-core
|
||||
flat_stream.cpp
|
||||
handler_ptr.cpp
|
||||
make_printable.cpp
|
||||
make_strand.cpp
|
||||
multi_buffer.cpp
|
||||
ostream.cpp
|
||||
rate_policy.cpp
|
||||
|
@@ -45,7 +45,6 @@ local SOURCES =
|
||||
flat_stream.cpp
|
||||
handler_ptr.cpp
|
||||
make_printable.cpp
|
||||
make_strand.cpp
|
||||
multi_buffer.cpp
|
||||
ostream.cpp
|
||||
rate_policy.cpp
|
||||
|
@@ -8,7 +8,6 @@
|
||||
//
|
||||
|
||||
#include <boost/beast/core/detail/config.hpp>
|
||||
#include <boost/beast/core/make_strand.hpp>
|
||||
#include <boost/beast/core/detail/get_io_context.hpp>
|
||||
#include <boost/beast/_experimental/unit_test/suite.hpp>
|
||||
#include <boost/asio/strand.hpp>
|
||||
@@ -32,7 +31,7 @@ public:
|
||||
BEAST_EXPECT(get_io_context(none{}) == nullptr);
|
||||
BEAST_EXPECT(get_io_context(ioc) == &ioc);
|
||||
BEAST_EXPECT(get_io_context(ioc.get_executor()) == &ioc);
|
||||
BEAST_EXPECT(get_io_context(make_strand(ioc)) == &ioc);
|
||||
BEAST_EXPECT(get_io_context(net::make_strand(ioc)) == &ioc);
|
||||
BEAST_EXPECT(get_io_context(net::executor(ioc.get_executor())) == &ioc);
|
||||
#if 0
|
||||
// VFALCO FIXME
|
||||
|
@@ -8,7 +8,7 @@
|
||||
//
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include <boost/beast/core/make_strand.hpp>
|
||||
#include <boost/beast/core/net::make_strand.hpp>
|
||||
|
||||
#include <boost/beast/_experimental/unit_test/suite.hpp>
|
||||
#include <boost/asio/executor.hpp>
|
||||
@@ -24,15 +24,15 @@ public:
|
||||
testFunction()
|
||||
{
|
||||
net::io_context ioc;
|
||||
make_strand(ioc);
|
||||
make_strand(ioc.get_executor());
|
||||
make_strand(make_strand(ioc));
|
||||
net::make_strand(ioc);
|
||||
net::make_strand(ioc.get_executor());
|
||||
net::make_strand(net::make_strand(ioc));
|
||||
|
||||
net::executor ex(ioc.get_executor());
|
||||
make_strand(ex);
|
||||
net::make_strand(ex);
|
||||
|
||||
// this *should-not* compile
|
||||
//make_strand(ex.context());
|
||||
//net::make_strand(ex.context());
|
||||
}
|
||||
|
||||
void
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(beast,core,make_strand);
|
||||
BEAST_DEFINE_TESTSUITE(beast,core,net::make_strand);
|
||||
|
||||
} // beast
|
||||
} // boost
|
||||
|
@@ -10,7 +10,6 @@
|
||||
// Test that header file is self-contained.
|
||||
#include <boost/beast/websocket/stream.hpp>
|
||||
|
||||
#include <boost/beast/core/make_strand.hpp>
|
||||
#include <boost/beast/core/tcp_stream.hpp>
|
||||
#include <boost/asio/strand.hpp>
|
||||
|
||||
@@ -158,7 +157,7 @@ public:
|
||||
{
|
||||
net::io_context ioc;
|
||||
{
|
||||
websocket::stream<tcp_stream> ws{make_strand(ioc)};
|
||||
websocket::stream<tcp_stream> ws{net::make_strand(ioc)};
|
||||
}
|
||||
{
|
||||
websocket::stream<tcp_stream> ws(ioc);
|
||||
|
@@ -69,7 +69,7 @@ core_3_timeouts_snippets()
|
||||
//[code_core_3_timeouts_3
|
||||
|
||||
// The strand will be used to invoke all completion handlers
|
||||
tcp_stream stream(make_strand(ioc));
|
||||
tcp_stream stream(net::make_strand(ioc));
|
||||
|
||||
//]
|
||||
|
||||
@@ -111,7 +111,7 @@ core_3_timeouts_snippets()
|
||||
// We construct the acceptor to use a new strand, and listen
|
||||
// on the loopback address with an operating-system assigned port.
|
||||
|
||||
net::ip::tcp::acceptor acceptor(make_strand(ioc));
|
||||
net::ip::tcp::acceptor acceptor(net::make_strand(ioc));
|
||||
acceptor.bind(net::ip::tcp::endpoint(net::ip::make_address_v4("127.0.0.1"), 0));
|
||||
acceptor.listen(0);
|
||||
|
||||
@@ -120,7 +120,7 @@ core_3_timeouts_snippets()
|
||||
// connected to the peer. The socket will have its own executor,
|
||||
// which in the call below is a new strand for the I/O context.
|
||||
|
||||
net::ip::tcp::socket s = acceptor.accept(make_strand(ioc));
|
||||
net::ip::tcp::socket s = acceptor.accept(net::make_strand(ioc));
|
||||
|
||||
// Construct a new tcp_stream from the connected socket.
|
||||
// The stream will use the strand created when the connection
|
||||
|
@@ -47,7 +47,7 @@ snippets()
|
||||
// The `tcp_stream` will be constructed with a new
|
||||
// strand which uses the specified I/O context.
|
||||
|
||||
stream<tcp_stream> ws(make_strand(ioc));
|
||||
stream<tcp_stream> ws(net::make_strand(ioc));
|
||||
|
||||
//]
|
||||
}
|
||||
@@ -76,7 +76,7 @@ snippets()
|
||||
//[code_websocket_5f
|
||||
|
||||
// The WebSocket stream will use SSL and a new strand
|
||||
stream<ssl_stream<tcp_stream>> wss(make_strand(ioc), ctx);
|
||||
stream<ssl_stream<tcp_stream>> wss(net::make_strand(ioc), ctx);
|
||||
|
||||
//]
|
||||
|
||||
|
@@ -58,7 +58,7 @@ snippets()
|
||||
//[code_websocket_1_3
|
||||
|
||||
// The stream will use the strand for invoking all completion handlers
|
||||
stream<tcp_stream> ws(make_strand(ioc));
|
||||
stream<tcp_stream> ws(net::make_strand(ioc));
|
||||
|
||||
// This overload of accept uses the socket provided for the new connection.
|
||||
// The function `tcp_stream::socket` provides access to the low-level socket
|
||||
|
Reference in New Issue
Block a user