basic_stream uses boost::shared_ptr

This commit is contained in:
Vinnie Falco
2019-02-14 12:54:32 -08:00
parent 65cbc158cf
commit 5ed9f7712e
3 changed files with 19 additions and 11 deletions

View File

@ -1,3 +1,9 @@
Version 215:
* basic_stream uses boost::shared_ptr
--------------------------------------------------------------------------------
Version 214:
* Handler binders use the associated allocator

View File

@ -21,8 +21,9 @@
#include <boost/core/empty_value.hpp>
#include <boost/config/workaround.hpp>
#include <boost/optional.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <boost/shared_ptr.hpp>
#include <chrono>
#include <memory>
namespace boost {
namespace asio {
@ -200,7 +201,7 @@ class basic_stream
public:
#endif
struct impl_type
: std::enable_shared_from_this<impl_type>
: boost::enable_shared_from_this<impl_type>
, boost::empty_value<Executor>
{
op_state read;
@ -227,7 +228,7 @@ public:
Executor const&
ex() const noexcept
{
return this->get();
return this->boost::empty_value<Executor>::get();
}
void reset(); // set timeouts to never
@ -241,7 +242,7 @@ private:
// outlive the destruction of the stream_socket object,
// in the case where there is no outstanding read or write
// but the implementation is still waiting on a timer.
std::shared_ptr<impl_type> impl_;
boost::shared_ptr<impl_type> impl_;
// Restricted until P1322R0 is incorporated into Boost.Asio.
static_assert(

View File

@ -17,6 +17,7 @@
#include <boost/asio/bind_executor.hpp>
#include <boost/asio/coroutine.hpp>
#include <boost/assert.hpp>
#include <boost/make_shared.hpp>
#include <boost/core/exchange.hpp>
#include <cstdlib>
#include <type_traits>
@ -118,7 +119,7 @@ struct basic_stream<
Protocol, Executor>::timeout_handler
{
op_state& state;
std::weak_ptr<impl_type> wp;
boost::weak_ptr<impl_type> wp;
tick_type tick;
void
@ -163,7 +164,7 @@ class basic_stream<Protocol, Executor>::async_op
: public async_op_base<Handler, Executor>
, public boost::asio::coroutine
{
std::shared_ptr<impl_type> impl_;
boost::shared_ptr<impl_type> impl_;
pending_guard pg_;
Buffers b_;
@ -292,7 +293,7 @@ class basic_stream_connect_op
using timeout_handler =
typename stream_type::timeout_handler;
std::shared_ptr<typename
boost::shared_ptr<typename
stream_type::impl_type> impl_;
typename stream_type::pending_guard pg0_;
typename stream_type::pending_guard pg1_;
@ -437,7 +438,7 @@ template<class Protocol, class Executor>
template<class ExecutionContext, class... Args, class>
basic_stream<Protocol, Executor>::
basic_stream(ExecutionContext& ctx, Args&&... args)
: impl_(std::make_shared<impl_type>(
: impl_(boost::make_shared<impl_type>(
ctx.get_executor(),
ctx, std::forward<Args>(args)...))
{
@ -452,7 +453,7 @@ template<class... Args>
basic_stream<Protocol, Executor>::
basic_stream(
executor_type const& ex, Args&&... args)
: impl_(std::make_shared<impl_type>(
: impl_(boost::make_shared<impl_type>(
ex,
ex.context(), std::forward<Args>(args)...))
{
@ -462,7 +463,7 @@ template<class Protocol, class Executor>
template<class OtherProtocol, class>
basic_stream<Protocol, Executor>::
basic_stream(net::basic_stream_socket<OtherProtocol>&& socket)
: impl_(std::make_shared<impl_type>(
: impl_(boost::make_shared<impl_type>(
std::move(socket),
std::is_constructible<Executor,
decltype(std::declval<net::basic_stream_socket<
@ -473,7 +474,7 @@ basic_stream(net::basic_stream_socket<OtherProtocol>&& socket)
template<class Protocol, class Executor>
basic_stream<Protocol, Executor>::
basic_stream(basic_stream&& other)
: impl_(std::make_shared<impl_type>(
: impl_(boost::make_shared<impl_type>(
std::move(*other.impl_)))
{
// VFALCO I'm not sure this implementation is correct...