Skip to content

Commit

Permalink
Fix overflow in register_timer functionality in GobyMOOSApp; also adj…
Browse files Browse the repository at this point in the history
…ust for time skews in system clock. Fixes #15
  • Loading branch information
tsaubergine committed Nov 1, 2016
1 parent b33c825 commit 686c955
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/moos/goby_moos_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ template <class MOOSAppType = MOOSAppShell>

struct SynchronousLoop
{
int unix_next;
double unix_next;
int period_seconds;
boost::function<void ()> handler;
};
Expand Down Expand Up @@ -368,7 +368,17 @@ template <class MOOSAppType>
{
loop.handler();
loop.unix_next += loop.period_seconds;

// fix jumps forward in time
if(loop.unix_next < now)
loop.unix_next = now + loop.period_seconds;

}

// fix jumps backwards in time
if(loop.unix_next > (now + 2*loop.period_seconds))
loop.unix_next = now + loop.period_seconds;

}
}

Expand Down

0 comments on commit 686c955

Please sign in to comment.