This commit is contained in:
2024-09-30 18:24:11 +03:00
parent 8aef1a7c25
commit 497b28f83e
2 changed files with 136 additions and 49 deletions

View File

@@ -219,6 +219,9 @@ public:
_socket(std::move(other._socket)),
_streamBuffer()
{
if (*this == other)
return;
auto bytes = asio::buffer_copy(_streamBuffer.prepare(other._streamBuffer.size()), other._streamBuffer.data());
_streamBuffer.commit(bytes);
};
@@ -228,6 +231,29 @@ public:
virtual ~AdcNetServiceASIOBase() {}
AdcNetServiceASIOBase& operator=(const AdcNetServiceASIOBase&) = delete;
AdcNetServiceASIOBase& operator=(AdcNetServiceASIOBase&& other)
{
if (*this != other) {
close();
_streamBuffer.consume(_streamBuffer.size());
auto bytes =
asio::buffer_copy(_streamBuffer.prepare(other._streamBuffer.size()), other._streamBuffer.data());
_streamBuffer.commit(bytes);
_ioContext = other._ioContext;
_receiveStrand = std::move(other._receiveStrand), _socket = std::move(other._socket);
_acceptor = std::move(other._acceptor);
_receiveQueue = other._receiveQueue;
}
return *this;
}
constexpr netservice_ident_t ident() const
{
return _ident;