mirror of
https://github.com/boostorg/asio.git
synced 2026-02-23 14:02:13 +00:00
Don't use shared_ptr in basic_socket_streambuf implementation.
This commit is contained in:
@@ -24,7 +24,6 @@
|
||||
#include <boost/asio/basic_socket.hpp>
|
||||
#include <boost/asio/basic_stream_socket.hpp>
|
||||
#include <boost/asio/detail/buffer_sequence_adapter.hpp>
|
||||
#include <boost/asio/detail/memory.hpp>
|
||||
#include <boost/asio/detail/throw_error.hpp>
|
||||
#include <boost/asio/io_context.hpp>
|
||||
|
||||
@@ -85,7 +84,28 @@ protected:
|
||||
{
|
||||
}
|
||||
|
||||
shared_ptr<io_context> default_io_context_;
|
||||
#if defined(BOOST_ASIO_HAS_MOVE)
|
||||
socket_streambuf_io_context(socket_streambuf_io_context&& other)
|
||||
: default_io_context_(other.default_io_context_)
|
||||
{
|
||||
other.default_io_context_ = 0;
|
||||
}
|
||||
|
||||
socket_streambuf_io_context& operator=(socket_streambuf_io_context&& other)
|
||||
{
|
||||
delete default_io_context_;
|
||||
default_io_context_ = other.default_io_context_;
|
||||
other.default_io_context_ = 0;
|
||||
return *this;
|
||||
}
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE)
|
||||
|
||||
io_context* default_io_context_;
|
||||
|
||||
private:
|
||||
// Disallow copying and assignment.
|
||||
socket_streambuf_io_context(const socket_streambuf_io_context&);
|
||||
socket_streambuf_io_context& operator=(const socket_streambuf_io_context&);
|
||||
};
|
||||
|
||||
// A separate base class is used to ensure that the dynamically allocated
|
||||
@@ -229,7 +249,7 @@ public:
|
||||
{
|
||||
this->close();
|
||||
socket() = std::move(other.socket());
|
||||
detail::socket_streambuf_io_context::operator=(other);
|
||||
detail::socket_streambuf_io_context::operator=(std::move(other));
|
||||
ec_ = other.ec_;
|
||||
expiry_time_ = other.expiry_time_;
|
||||
get_buffer_.swap(other.get_buffer_);
|
||||
|
||||
Reference in New Issue
Block a user