Skip to content

Commit

Permalink
Update ProtocolMessage and ProtocolWrapper moving.
Browse files Browse the repository at this point in the history
  • Loading branch information
Barenboim committed Aug 20, 2024
1 parent dbdce1b commit 7462bec
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/protocol/ProtocolMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class ProtocolMessage : public CommMessageOut, public CommMessageIn
this->size_limit = message.size_limit;
this->attachment = message.attachment;
message.attachment = NULL;
this->wrapper = message.wrapper;
this->wrapper = NULL;
}

ProtocolMessage& operator = (ProtocolMessage&& message)
Expand All @@ -117,7 +117,6 @@ class ProtocolMessage : public CommMessageOut, public CommMessageIn
delete this->attachment;
this->attachment = message.attachment;
message.attachment = NULL;
this->wrapper = message.wrapper;
}

return *this;
Expand Down Expand Up @@ -145,22 +144,28 @@ class ProtocolWrapper : public ProtocolMessage
return this->message->inner();
}

protected:
void set_message(ProtocolMessage *message)
{
this->message = message;
if (message)
message->wrapper = this;
}

protected:
ProtocolMessage *message;

public:
ProtocolWrapper(ProtocolMessage *message)
{
message->wrapper = this;
this->message = message;
this->set_message(message);
}

public:
ProtocolWrapper(ProtocolWrapper&& wrapper) :
ProtocolMessage(std::move(wrapper))
{
wrapper.message->wrapper = this;
this->message = wrapper.message;
this->set_message(wrapper.message);
wrapper.message = NULL;
}

Expand All @@ -169,8 +174,7 @@ class ProtocolWrapper : public ProtocolMessage
if (&wrapper != this)
{
*(ProtocolMessage *)this = std::move(wrapper);
wrapper.message->wrapper = this;
this->message = wrapper.message;
this->set_message(wrapper.message);
wrapper.message = NULL;
}

Expand Down

0 comments on commit 7462bec

Please sign in to comment.