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

common/util: refactor sleep_for for high-precision sleep #33281

Closed
wants to merge 1 commit into from

Conversation

deanlee
Copy link
Contributor

@deanlee deanlee commented Aug 13, 2024

Changes:

  1. Refactored util::sleep_for to use clock_nanosleep (or nanosleep on macOS) for more accurate sleep durations than std::thread::sleep_for, especially for very short sleep durations.
  2. support double values for fractional millisecond timing.

This refactor enhances sleep precision across C++ modules, with significant benefits for the RateKeeper class: It also improves event scheduling accuracy in Python modules that rely on stable rate keeping provided by the RateKeeper in the C++ module.

Copy link
Contributor

github-actions bot commented Aug 13, 2024

Thanks for contributing to openpilot! In order for us to review your PR as quickly as possible, check the following:

  • Convert your PR to a draft unless it's ready to review
  • Read the contributing docs
  • Before marking as "ready for review", ensure:
    • the goal is clearly stated in the description
    • all the tests are passing
    • the change is something we merge
    • include a route or your device' dongle ID if relevant

@deanlee deanlee marked this pull request as ready for review August 13, 2024 09:29
@deanlee deanlee marked this pull request as draft August 14, 2024 07:01
@deanlee deanlee closed this Aug 14, 2024
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.

1 participant