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

associated clocks should be protected by mutex. (backport #2255) #2259

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions rclcpp/src/rclcpp/time_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class ClocksState final
ros_time_active_ = true;

// Update all attached clocks to zero or last recorded time
<<<<<<< HEAD
std::lock_guard<std::mutex> guard(clock_list_lock_);
auto time_msg = std::make_shared<builtin_interfaces::msg::Time>();
if (last_msg_set_) {
Expand All @@ -61,6 +62,9 @@ class ClocksState final
for (auto it = associated_clocks_.begin(); it != associated_clocks_.end(); ++it) {
set_clock(time_msg, true, *it);
}
=======
set_all_clocks(last_time_msg_, true);
>>>>>>> 5d6e5fa7 (associated clocks should be protected by mutex. (#2255))
}

// An internal method to use in the clock callback that iterates and disables all clocks
Expand All @@ -75,11 +79,8 @@ class ClocksState final
ros_time_active_ = false;

// Update all attached clocks
std::lock_guard<std::mutex> guard(clock_list_lock_);
for (auto it = associated_clocks_.begin(); it != associated_clocks_.end(); ++it) {
auto msg = std::make_shared<builtin_interfaces::msg::Time>();
set_clock(msg, false, *it);
}
auto msg = std::make_shared<builtin_interfaces::msg::Time>();
set_all_clocks(msg, false);
}

// Check if ROS time is active
Expand Down