for timeout / refresh_rate times do
is_done <- body()
if is_done then break
wait refresh_rate
end for
However, the execution time of the body is not always negligible. Especially for small refresh rates the body time becomes extremely significant, in some cases ~6-60x the refresh rate. In these cases the wall time of the timeout is proportionally affected. That is, timeouts become 6-60x longer than specified.
Instead timeouts should be measured using a pure wall time approach,
t_start <- get_time()
t_end <- get_time()
while t_end - t_start < timeout do
is_done <- body()
if is_done then break
wait refresh_rate
t_end <- get_time()
end while
By factoring in the body time, this should keep them accurate.
Timeouts are currently measured by,
However, the execution time of the body is not always negligible. Especially for small refresh rates the body time becomes extremely significant, in some cases ~6-60x the refresh rate. In these cases the wall time of the timeout is proportionally affected. That is, timeouts become 6-60x longer than specified.
Instead timeouts should be measured using a pure wall time approach,
By factoring in the body time, this should keep them accurate.