FairMQ: add FairMQMessage::Copy(const FairMQMessage& msg), deprecate the old one.

This commit is contained in:
Alexey Rybalchenko
2017-12-08 12:02:08 +01:00
committed by Mohammad Al-Turany
parent e340a52bf2
commit ba78964e29
10 changed files with 90 additions and 21 deletions

View File

@@ -112,7 +112,7 @@ void FairMQMessageZMQ::Rebuild(void* data, const size_t size, fairmq_free_fn* ff
}
}
zmq_msg_t* FairMQMessageZMQ::GetMessage()
zmq_msg_t* FairMQMessageZMQ::GetMessage() const
{
if (!fViewMsg)
{
@@ -124,7 +124,7 @@ zmq_msg_t* FairMQMessageZMQ::GetMessage()
}
}
void* FairMQMessageZMQ::GetData()
void* FairMQMessageZMQ::GetData() const
{
if (!fViewMsg)
{
@@ -195,6 +195,24 @@ FairMQ::Transport FairMQMessageZMQ::GetType() const
return fTransportType;
}
void FairMQMessageZMQ::Copy(const FairMQMessage& msg)
{
const FairMQMessageZMQ& zMsg = static_cast<const FairMQMessageZMQ&>(msg);
// Shares the message buffer between msg and this fMsg.
if (zmq_msg_copy(fMsg.get(), zMsg.GetMessage()) != 0)
{
LOG(ERROR) << "failed copying message, reason: " << zmq_strerror(errno);
return;
}
// if the target message has been resized, apply same to this message also
if (zMsg.fUsedSizeModified)
{
fUsedSizeModified = true;
fUsedSize = zMsg.fUsedSize;
}
}
void FairMQMessageZMQ::Copy(const FairMQMessagePtr& msg)
{
FairMQMessageZMQ* msgPtr = static_cast<FairMQMessageZMQ*>(msg.get());