Update rcutils_steady_time_now to return the same data as std::chrono#357
Merged
clalancette merged 2 commits intomasterfrom Apr 27, 2022
Merged
Update rcutils_steady_time_now to return the same data as std::chrono#357clalancette merged 2 commits intomasterfrom
clalancette merged 2 commits intomasterfrom
Conversation
Based on an investigation several years ago, rcutils_steady_time_now has slightly different behavior than std::chrono::now . In particular, on Linux rcutils_steady_time_now was using CLOCK_MONOTONIC_RAW, while std::chrono is using CLOCK_MONOTONIC. On macOS, rcutils_steady_time_now was using SYSTEM_CLOCK, while std::chrono was using CLOCK_MONOTONIC_RAW. Fix both of these so they match what std::chrono does, and in the case of macOS, significantly simplify the code by switching to clock_gettime. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
fujitatomoya
approved these changes
Apr 23, 2022
Collaborator
fujitatomoya
left a comment
There was a problem hiding this comment.
lgtm, aligned with std::chrono would be better for user application.
With this, all of the tests seem to pass. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
Contributor
Author
Contributor
Author
|
The test failing on Windows shows up in the Windows repeated jobs as well: https://ci.ros2.org/view/nightly/job/nightly_win_rep/2596 . So I'm going to go ahead and merge this, thanks for the reviews. |
alsora
pushed a commit
to irobot-ros/rcutils
that referenced
this pull request
Jul 28, 2023
…ros2#357) * Update rcutils_steady_time_now to return the same data as std::chrono Based on an investigation several years ago, rcutils_steady_time_now has slightly different behavior than std::chrono::now . In particular, on Linux rcutils_steady_time_now was using CLOCK_MONOTONIC_RAW, while std::chrono is using CLOCK_MONOTONIC. On macOS, rcutils_steady_time_now was using SYSTEM_CLOCK, while std::chrono was using CLOCK_MONOTONIC_RAW. Fix both of these so they match what std::chrono does, and in the case of macOS, significantly simplify the code by switching to clock_gettime. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
alsora
pushed a commit
to irobot-ros/rcutils
that referenced
this pull request
Jul 28, 2023
…ros2#357) * Update rcutils_steady_time_now to return the same data as std::chrono Based on an investigation several years ago, rcutils_steady_time_now has slightly different behavior than std::chrono::now . In particular, on Linux rcutils_steady_time_now was using CLOCK_MONOTONIC_RAW, while std::chrono is using CLOCK_MONOTONIC. On macOS, rcutils_steady_time_now was using SYSTEM_CLOCK, while std::chrono was using CLOCK_MONOTONIC_RAW. Fix both of these so they match what std::chrono does, and in the case of macOS, significantly simplify the code by switching to clock_gettime. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Based on an investigation several years ago, rcutils_steady_time_now
has slightly different behavior than std::chrono::now . In
particular, on Linux rcutils_steady_time_now was using
CLOCK_MONOTONIC_RAW, while std::chrono is using CLOCK_MONOTONIC.
On macOS, rcutils_steady_time_now was using SYSTEM_CLOCK, while std::chrono
was using CLOCK_MONOTONIC_RAW. Fix both of these so they
match what std::chrono does, and in the case of macOS, significantly
simplify the code by switching to clock_gettime.
Signed-off-by: Chris Lalancette clalancette@openrobotics.org
This should fix #43 . Draft for now, as I haven't even compile tested this on macOS yet.