Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sytelus committed Nov 18, 2017
1 parent 8e4f275 commit 65d917d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion AirLib/include/common/common_utils/ScheduledExecutor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ class ScheduledExecutor {
call_end = nanos();

TTimeDelta elapsed_period = nanos() - period_start;
TTimeDelta delay_nanos = period_nanos_ - elapsed_period;
//prevent underflow: https://github.com/Microsoft/AirSim/issues/617
TTimeDelta delay_nanos = period_nanos_ > elapsed_period ? period_nanos_ - elapsed_period : 0;
//moving average of how much we are sleeping
sleep_time_avg_ = 0.25f * sleep_time_avg_ + 0.75f * delay_nanos;
++period_count_;
Expand Down

0 comments on commit 65d917d

Please sign in to comment.