Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add MonotonicTimer #1003

Closed
wants to merge 1 commit into from
Closed

add MonotonicTimer #1003

wants to merge 1 commit into from

Conversation

flixr
Copy link
Contributor

@flixr flixr commented Feb 26, 2017

based on MonotonicTime (which uses the CLOCK_MONOTONIC).
This timer is not influenced by time jumps of the system time,
so ideal for things like periodic checks of timeout/heartbeat, etc...

Depends on ros/roscpp_core#55

based on MonotonicTime (which uses the CLOCK_MONOTONIC).
This timer is not influenced by time jumps of the system time,
so ideal for things like periodic checks of timeout/heartbeat, etc...
@flixr
Copy link
Contributor Author

flixr commented Feb 27, 2017

So while in theory this should work well, it seems that there is a bug in the boost condition timed_wait:
Even if you pass it a duration it will simply add it to the current system time and wait until then.
It seems to be fixed in boost 1.61 if you specify BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC, see https://svn.boost.org/trac/boost/ticket/6377

So that means that currently the MonotonicTimer can nicely deal with forward jumps in time, but not with backwards jumps.

Possible solutions:

  • also only wait for 1ms just like in the sim time case and re-check the sleep_end predicate
    • drawback is that you up a lot more often than needed
    • to do this only for the MonotonicTimer we either need to add a member function isMonotonicTime or use a typeid check?
  • replace the boost condition variable with C++11 equivalent where you can specify it to use a monotonic clock

@flixr flixr mentioned this pull request Mar 6, 2017
@flixr
Copy link
Contributor Author

flixr commented Mar 6, 2017

Closing in favor of #1014

@flixr flixr closed this Mar 6, 2017
@flixr flixr deleted the monotonic_timer branch March 6, 2017 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant