From 156b8f9c39a81cbbad7c32dbebdf321787611779 Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Wed, 22 Mar 2017 16:40:15 +0000 Subject: Send diag request only if not other one with some id running Fix: elapsed function return that do not compute elapsed_time at first time Fix: reworked should_send() to get it work with our scheduling workflow Reschedule trying to send request if recurring even it is in flight. Change-Id: Idce54cb9bf62616c891a8a25a6c478f931350bc7 Signed-off-by: Romain Forlot --- src/utils/timer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/utils') diff --git a/src/utils/timer.cpp b/src/utils/timer.cpp index 7c2560e..540cfe0 100644 --- a/src/utils/timer.cpp +++ b/src/utils/timer.cpp @@ -73,7 +73,7 @@ bool frequency_clock_t::started() time_function_t frequency_clock_t::get_time_function() { - return time_function_ != nullptr ? time_function_ : system_time_ms; + return time_function_ != nullptr ? time_function_ : system_time_us; } bool frequency_clock_t::elapsed(bool stagger) @@ -82,9 +82,9 @@ bool frequency_clock_t::elapsed(bool stagger) float elapsed_time = 0; if(!started() && stagger) last_tick_ = get_time_function()() - (rand() % int(period)); - else - // Make sure it ticks the the first call - elapsed_time = !started() ? period : get_time_function()() - last_tick_; + + // Make sure it ticks the the first call + elapsed_time = !started() ? period : get_time_function()() - last_tick_; return frequency_ == 0 || elapsed_time >= period; } -- cgit 1.2.3-korg