mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-15 09:31:45 +00:00
Add new Send/Receive methods with smart pointers and no flag checks.
This commit is contained in:
committed by
Mohammad Al-Turany
parent
105e734808
commit
a7ab33a10e
@@ -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!";
|
||||
|
Reference in New Issue
Block a user