mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-15 09:31:45 +00:00
Add -i option as exit condition
After -i# iterations sampler and sink will exit RUNNING state.
This commit is contained in:
committed by
Dennis Klein
parent
14980d7486
commit
b53691c8ad
@@ -26,6 +26,12 @@ Sampler::Sampler()
|
||||
{
|
||||
}
|
||||
|
||||
void Sampler::InitTask()
|
||||
{
|
||||
fIterations = fConfig->GetValue<uint64_t>("iterations");
|
||||
fCounter = 0;
|
||||
}
|
||||
|
||||
bool Sampler::ConditionalRun()
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
@@ -43,6 +49,14 @@ bool Sampler::ConditionalRun()
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fIterations > 0) {
|
||||
++fCounter;
|
||||
if (fCounter >= fIterations) {
|
||||
LOG(info) << "Sent " << fCounter << " messages. Finished.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user