FairMQ: Move static and interactive control modes to plugin (2)

This commit is contained in:
Alexey Rybalchenko
2017-09-14 12:42:07 +02:00
committed by Mohammad Al-Turany
parent 10f67e4c72
commit 334b91785b
15 changed files with 246 additions and 138 deletions

View File

@@ -16,7 +16,6 @@
#include <vector>
#include <chrono>
#include <thread>
#include "../FairMQLogger.h"
#include "../options/FairMQProgOptions.h"
@@ -30,6 +29,7 @@ FairMQBenchmarkSampler::FairMQBenchmarkSampler()
, fMsgRate(1)
, fNumMsgs(0)
, fOutChannelName()
, fResetMsgCounter()
{
}
@@ -46,10 +46,13 @@ void FairMQBenchmarkSampler::InitTask()
fOutChannelName = fConfig->GetValue<string>("out-channel");
}
void FairMQBenchmarkSampler::PreRun()
{
fResetMsgCounter = std::thread(&FairMQBenchmarkSampler::ResetMsgCounter, this);
}
void FairMQBenchmarkSampler::Run()
{
std::thread resetMsgCounter(&FairMQBenchmarkSampler::ResetMsgCounter, this);
uint64_t numSentMsgs = 0;
// store the channel reference to avoid traversing the map on every loop iteration
@@ -108,7 +111,11 @@ void FairMQBenchmarkSampler::Run()
LOG(INFO) << "Leaving RUNNING state. Sent " << numSentMsgs << " messages in " << chrono::duration<double, milli>(tEnd - tStart).count() << "ms.";
resetMsgCounter.join();
}
void FairMQBenchmarkSampler::PostRun()
{
fResetMsgCounter.join();
}
void FairMQBenchmarkSampler::ResetMsgCounter()

View File

@@ -16,6 +16,7 @@
#define FAIRMQBENCHMARKSAMPLER_H_
#include <string>
#include <thread>
#include "FairMQDevice.h"
@@ -29,6 +30,9 @@ class FairMQBenchmarkSampler : public FairMQDevice
FairMQBenchmarkSampler();
virtual ~FairMQBenchmarkSampler();
void PreRun() override;
void PostRun() override;
void ResetMsgCounter();
protected:
@@ -38,6 +42,7 @@ class FairMQBenchmarkSampler : public FairMQDevice
int fMsgRate;
uint64_t fNumMsgs;
std::string fOutChannelName;
std::thread fResetMsgCounter;
virtual void InitTask();
virtual void Run();