mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 08:41:16 +00:00
using steady_clock instead of system_clock
This commit is contained in:
parent
4351f3df0d
commit
72cdd1e3d7
|
@ -514,19 +514,19 @@ void FairMQDevice::RunWrapper()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
using Clock = std::chrono::steady_clock;
|
||||||
|
using TimeScale = std::chrono::microseconds;
|
||||||
|
const TimeScale::rep period = TimeScale::period::den / fRate;
|
||||||
|
const auto reftime = Clock::now();
|
||||||
while (CheckCurrentState(RUNNING) && ConditionalRun())
|
while (CheckCurrentState(RUNNING) && ConditionalRun())
|
||||||
{
|
{
|
||||||
using TimeScale = std::chrono::microseconds;
|
|
||||||
static const auto reftime = std::chrono::system_clock::now();
|
|
||||||
if (fRate > 0.001) {
|
if (fRate > 0.001) {
|
||||||
auto timeSinceRef = std::chrono::duration_cast<TimeScale>(std::chrono::system_clock::now() - reftime);
|
auto timespan = std::chrono::duration_cast<TimeScale>(Clock::now() - reftime).count() - fLastTime;
|
||||||
auto timespan = timeSinceRef.count() - fLastTime;
|
|
||||||
TimeScale::rep period = static_cast<float>(TimeScale::period::den) / fRate;
|
|
||||||
if (timespan < period) {
|
if (timespan < period) {
|
||||||
TimeScale sleepfor(period - timespan);
|
TimeScale sleepfor(period - timespan);
|
||||||
std::this_thread::sleep_for(sleepfor);
|
std::this_thread::sleep_for(sleepfor);
|
||||||
}
|
}
|
||||||
fLastTime = std::chrono::duration_cast<TimeScale>(std::chrono::system_clock::now() - reftime).count();
|
fLastTime = std::chrono::duration_cast<TimeScale>(Clock::now() - reftime).count();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user