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

@@ -71,17 +71,18 @@ class GenericFileSink : public FairMQDevice, public InputPolicy, public OutputPo
{
int receivedMsg = 0;
while (GetCurrentState() == RUNNING)
{
FairMQMessage* msg = fTransportFactory->CreateMessage();
// store the channel reference to avoid traversing the map on every loop iteration
const FairMQChannel& inputChannel = fChannels["data-in"].at(0);
if (fChannels["data-in"].at(0).Receive(msg) > 0)
while (CheckCurrentState(RUNNING))
{
std::unique_ptr<FairMQMessage> msg(fTransportFactory->CreateMessage());
if (inputChannel.Receive(msg) > 0)
{
OutputPolicy::AddToFile(InputPolicy::DeSerializeMsg(msg));
OutputPolicy::AddToFile(InputPolicy::DeSerializeMsg(msg.get()));
receivedMsg++;
}
delete msg;
}
MQLOG(INFO) << "Received " << receivedMsg << " messages!";