From 71c7ac8bb9a1f73a26f95171e90660891a43a0ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Bourdeauducq?= Date: Sun, 19 Jan 2025 18:23:09 +0800 Subject: [PATCH] clocker: minor simplification --- dsp_lib.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dsp_lib.hpp b/dsp_lib.hpp index 85d0550..4aab1f7 100644 --- a/dsp_lib.hpp +++ b/dsp_lib.hpp @@ -82,14 +82,14 @@ class Clocker { Clocker(std::chrono::milliseconds period): period(period) {}; void tick() { if(next_tick == std::chrono::time_point::min()) { - next_tick = std::chrono::steady_clock::now() + period; + next_tick = std::chrono::steady_clock::now(); } else { + next_tick += period; auto duration = next_tick - std::chrono::steady_clock::now(); if(duration >= duration.zero()) std::this_thread::sleep_for(duration); else std::cerr << "missed tick" << std::endl; - next_tick += period; } } };