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

@@ -120,31 +120,29 @@ class GenericProcessor : public FairMQDevice, public InputPolicy, public OutputP
int receivedMsgs = 0;
int sentMsgs = 0;
const FairMQChannel& inputChannel = fChannels["data-in"].at(0);
const FairMQChannel& outputChannel = fChannels["data-out"].at(0);
while (CheckCurrentState(RUNNING))
{
FairMQMessage* msg = fTransportFactory->CreateMessage();
std::unique_ptr<FairMQMessage> msg(fTransportFactory->CreateMessage());
++receivedMsgs;
if (fChannels["data-in"].at(0).Receive(msg) > 0)
if (inputChannel.Receive(msg) > 0)
{
// InputPolicy::DeSerializeMsg(msg) --> deserialize data of msg and fill output container
// TaskPolicy::ExecuteTask( ... ) --> process output container
TaskPolicy::ExecuteTask(InputPolicy::DeSerializeMsg(msg));
TaskPolicy::ExecuteTask(InputPolicy::DeSerializeMsg(msg.get()));
// OutputPolicy::fMessage point to msg
OutputPolicy::SetMessage(msg);
OutputPolicy::SetMessage(msg.get());
// TaskPolicy::GetOutputData() --> Get processed output container
// OutputPolicy::message(...) --> Serialize output container and fill fMessage
fChannels["data-out"].at(0).Send(OutputPolicy::SerializeMsg(TaskPolicy::GetOutputData()));
outputChannel.Send(OutputPolicy::SerializeMsg(TaskPolicy::GetOutputData()));
sentMsgs++;
}
if (msg)
{
msg->CloseMessage();
}
}
MQLOG(INFO) << "Received " << receivedMsgs << " and sent " << sentMsgs << " messages!";