mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-15 09:31:45 +00:00
Tests for MQ examples
This commit is contained in:
committed by
Mohammad Al-Turany
parent
984eed1a89
commit
319bdc91a1
@@ -14,14 +14,23 @@
|
||||
|
||||
#include "FairMQExample5Server.h"
|
||||
#include "FairMQLogger.h"
|
||||
#include "FairMQProgOptions.h" // device->fConfig
|
||||
|
||||
using namespace std;
|
||||
|
||||
FairMQExample5Server::FairMQExample5Server()
|
||||
: fMaxIterations(0)
|
||||
, fNumIterations(0)
|
||||
{
|
||||
OnData("data", &FairMQExample5Server::HandleData);
|
||||
}
|
||||
|
||||
void FairMQExample5Server::InitTask()
|
||||
{
|
||||
// Get the fMaxIterations value from the command line options (via fConfig)
|
||||
fMaxIterations = fConfig->GetValue<uint64_t>("max-iterations");
|
||||
}
|
||||
|
||||
bool FairMQExample5Server::HandleData(FairMQMessagePtr& request, int /*index*/)
|
||||
{
|
||||
LOG(INFO) << "Received request from client: \"" << string(static_cast<char*>(request->GetData()), request->GetSize()) << "\"";
|
||||
@@ -37,6 +46,12 @@ bool FairMQExample5Server::HandleData(FairMQMessagePtr& request, int /*index*/)
|
||||
|
||||
if (Send(reply, "data") > 0)
|
||||
{
|
||||
if (fMaxIterations > 0 && ++fNumIterations >= fMaxIterations)
|
||||
{
|
||||
LOG(INFO) << "Configured maximum number of iterations reached. Leaving RUNNING state.";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user