Add new Send/Receive methods with smart pointers and no flag checks.

This commit is contained in:
Alexey Rybalchenko
2015-08-17 14:45:31 +02:00
committed by Mohammad Al-Turany
parent 105e734808
commit a7ab33a10e
22 changed files with 204 additions and 121 deletions

View File

@@ -95,6 +95,24 @@ void FairMQMessageZMQ::SetMessage(void* data, size_t size)
}
void FairMQMessageZMQ::Copy(FairMQMessage* msg)
{
// DEPRECATED: Use Copy(const unique_ptr<FairMQMessage>&)
// Shares the message buffer between msg and this fMessage.
if (zmq_msg_copy(&fMessage, (zmq_msg_t*)msg->GetMessage()) != 0)
{
LOG(ERROR) << "failed copying message, reason: " << zmq_strerror(errno);
}
// Alternatively, following code does a hard copy of the message, which allows to modify the original after making a copy, without affecting the new msg.
// CloseMessage();
// size_t size = msg->GetSize();
// zmq_msg_init_size(&fMessage, size);
// memcpy(zmq_msg_data(&fMessage), msg->GetData(), size);
}
void FairMQMessageZMQ::Copy(const unique_ptr<FairMQMessage>& msg)
{
// Shares the message buffer between msg and this fMessage.
if (zmq_msg_copy(&fMessage, (zmq_msg_t*)msg->GetMessage()) != 0)

View File

@@ -40,6 +40,7 @@ class FairMQMessageZMQ : public FairMQMessage
virtual void CloseMessage();
virtual void Copy(FairMQMessage* msg);
virtual void Copy(const std::unique_ptr<FairMQMessage>& msg);
static void CleanUp(void* data, void* hint);