mirror of
https://github.com/sogou/workflow.git
synced 2026-02-08 01:33:17 +08:00
Update ProtocolMessage and ProtocolWrapper moving. (#1612)
This commit is contained in:
@@ -39,7 +39,7 @@ int PackageWrapper::encode(struct iovec vectors[], int max)
|
||||
}
|
||||
|
||||
cnt += ret;
|
||||
this->message = this->next_out(this->message);
|
||||
this->set_message(this->next_out(this->message));
|
||||
if (!this->message)
|
||||
return cnt;
|
||||
|
||||
@@ -57,7 +57,7 @@ int PackageWrapper::append(const void *buf, size_t *size)
|
||||
|
||||
if (ret > 0)
|
||||
{
|
||||
this->message = this->next_in(this->message);
|
||||
this->set_message(this->next_in(this->message));
|
||||
if (this->message)
|
||||
{
|
||||
this->renew();
|
||||
|
||||
@@ -114,7 +114,7 @@ public:
|
||||
this->size_limit = message.size_limit;
|
||||
this->attachment = message.attachment;
|
||||
message.attachment = NULL;
|
||||
this->wrapper = message.wrapper;
|
||||
this->wrapper = NULL;
|
||||
}
|
||||
|
||||
ProtocolMessage& operator = (ProtocolMessage&& message)
|
||||
@@ -125,7 +125,6 @@ public:
|
||||
delete this->attachment;
|
||||
this->attachment = message.attachment;
|
||||
message.attachment = NULL;
|
||||
this->wrapper = message.wrapper;
|
||||
}
|
||||
|
||||
return *this;
|
||||
@@ -153,22 +152,28 @@ protected:
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -177,8 +182,7 @@ public:
|
||||
if (&wrapper != this)
|
||||
{
|
||||
*(ProtocolMessage *)this = std::move(wrapper);
|
||||
wrapper.message->wrapper = this;
|
||||
this->message = wrapper.message;
|
||||
this->set_message(wrapper.message);
|
||||
wrapper.message = NULL;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user