mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 08:41:16 +00:00
Use new RateLimiter for ConditionalRun
This commit is contained in:
parent
6545daeda7
commit
2498837b8e
|
@ -64,8 +64,6 @@ bool Sampler::ConditionalRun()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this_thread::sleep_for(chrono::seconds(1));
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ export FAIRMQ_PATH=@FAIRMQ_BIN_DIR@
|
||||||
|
|
||||||
SAMPLER="fairmq-ex-1-1-sampler"
|
SAMPLER="fairmq-ex-1-1-sampler"
|
||||||
SAMPLER+=" --id sampler1"
|
SAMPLER+=" --id sampler1"
|
||||||
|
SAMPLER+=" --rate 1"
|
||||||
SAMPLER+=" --channel-config name=data,type=push,method=bind,address=tcp://*:5555,rateLogging=0"
|
SAMPLER+=" --channel-config name=data,type=push,method=bind,address=tcp://*:5555,rateLogging=0"
|
||||||
xterm -geometry 80x23+0+0 -hold -e @EX_BIN_DIR@/$SAMPLER &
|
xterm -geometry 80x23+0+0 -hold -e @EX_BIN_DIR@/$SAMPLER &
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ trap 'kill -TERM $SAMPLER_PID; kill -TERM $SINK_PID; wait $SAMPLER_PID; wait $SI
|
||||||
|
|
||||||
SAMPLER="fairmq-ex-1-1-sampler"
|
SAMPLER="fairmq-ex-1-1-sampler"
|
||||||
SAMPLER+=" --id sampler1"
|
SAMPLER+=" --id sampler1"
|
||||||
|
SAMPLER+=" --rate 1"
|
||||||
SAMPLER+=" --transport $transport"
|
SAMPLER+=" --transport $transport"
|
||||||
SAMPLER+=" --verbosity veryhigh"
|
SAMPLER+=" --verbosity veryhigh"
|
||||||
SAMPLER+=" --control static --color false"
|
SAMPLER+=" --control static --color false"
|
||||||
|
|
|
@ -71,7 +71,6 @@ FairMQDevice::FairMQDevice(FairMQProgOptions* config, const fair::mq::tools::Ver
|
||||||
, fMultitransportProceed(false)
|
, fMultitransportProceed(false)
|
||||||
, fVersion(version)
|
, fVersion(version)
|
||||||
, fRate(0.)
|
, fRate(0.)
|
||||||
, fLastTime(0)
|
|
||||||
, fRawCmdLineArgs()
|
, fRawCmdLineArgs()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -516,19 +515,13 @@ void FairMQDevice::RunWrapper()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
using Clock = chrono::steady_clock;
|
fair::mq::tools::RateLimiter rateLimiter(fRate);
|
||||||
using TimeScale = chrono::microseconds;
|
|
||||||
const TimeScale::rep period = TimeScale::period::den / fRate;
|
|
||||||
const auto reftime = Clock::now();
|
|
||||||
while (CheckCurrentState(RUNNING) && ConditionalRun())
|
while (CheckCurrentState(RUNNING) && ConditionalRun())
|
||||||
{
|
{
|
||||||
if (fRate > 0.001) {
|
if (fRate > 0.001)
|
||||||
auto timespan = static_cast<TimeScale::rep>(chrono::duration_cast<TimeScale>(Clock::now() - reftime).count() - fLastTime);
|
{
|
||||||
if (timespan < period) {
|
rateLimiter.maybe_sleep();
|
||||||
TimeScale sleepfor(period - timespan);
|
|
||||||
this_thread::sleep_for(sleepfor);
|
|
||||||
}
|
|
||||||
fLastTime = chrono::duration_cast<TimeScale>(Clock::now() - reftime).count();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -550,7 +550,6 @@ class FairMQDevice : public FairMQStateMachine
|
||||||
|
|
||||||
const fair::mq::tools::Version fVersion;
|
const fair::mq::tools::Version fVersion;
|
||||||
float fRate; ///< Rate limiting for ConditionalRun
|
float fRate; ///< Rate limiting for ConditionalRun
|
||||||
size_t fLastTime; ///< Rate limiting for ConditionalRun
|
|
||||||
std::vector<std::string> fRawCmdLineArgs;
|
std::vector<std::string> fRawCmdLineArgs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user