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 callbacks for PlayerClock::jump(time_point) API with CI fix #779

Merged

Conversation

MichaelOrlov
Copy link
Contributor

Add callbacks for PlayerClock::jump(time_point) API
Part of #696

Reapply changes from #775 with CI fix for Windows build.

Signed-off-by: Michael Orlov <michael.orlov@apex.ai>
@MichaelOrlov
Copy link
Contributor Author

Gist: https://gist.githubusercontent.com/MichaelOrlov/017e746f8540278a3398bff0770d7dc7/raw/3646eee77875a931bc2b4cd92642a0bc0570f4d2/ros2.repos
BUILD args: --packages-up-to rosbag2_cpp rosbag2_tests
TEST args: --packages-select rosbag2_cpp rosbag2_tests
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/8566

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@MichaelOrlov MichaelOrlov marked this pull request as ready for review June 12, 2021 01:29
@MichaelOrlov MichaelOrlov requested a review from a team as a code owner June 12, 2021 01:29
@MichaelOrlov MichaelOrlov requested review from mjeronimo and jhdcs and removed request for a team June 12, 2021 01:29
Copy link
Contributor

@jhdcs jhdcs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, only some minor things I've noticed and commented on.

{
rcl_duration_t time_jump_delta;
{
std::lock_guard<std::mutex> lock(state_mutex);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since ROS 2 supports C++ 17, we now have access to the std::scoped_lock class. Should we use that here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We haven't yet changed rosbag2 to target C++17 - this is an upgrade that could be done in a new PR if we're inclined

void remove_jump_callbacks(PlayerClock::JumpHandler::SharedPtr handler)
{
std::lock_guard<std::mutex> lock(callback_list_mutex_);
for (auto it = callback_list_.begin(); it != callback_list_.end(); ++it) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function name and comment make it sound like this will remove multiple jump callbacks from the processing list. However, the code only removes one. Should the comment/function name change to make it more clear that we're removing one callback?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A JumpHandler contains multiple callback functions. Maybe remove_jump_handler would be more clear - but the language is consistent

handler->pre_callback();
} else if (!before_jump && handler->post_callback) {
handler->post_callback(time_jump);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no else statement here. If this is intentional, can we add a comment stating that we intend to do nothing?

@emersonknapp emersonknapp self-requested a review June 14, 2021 23:58
@emersonknapp emersonknapp merged commit 6f7503e into master Jun 15, 2021
@delete-merged-branch delete-merged-branch bot deleted the michaelorlov/player-clock_jump_callbacks-with-win-fix branch June 15, 2021 00:00
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

3 participants