diff --git a/rclcpp/src/rclcpp/time_source.cpp b/rclcpp/src/rclcpp/time_source.cpp index 7f3b3b9536..e5c9b994f2 100644 --- a/rclcpp/src/rclcpp/time_source.cpp +++ b/rclcpp/src/rclcpp/time_source.cpp @@ -54,9 +54,7 @@ class ClocksState final ros_time_active_ = true; // Update all attached clocks to zero or last recorded time - for (auto it = associated_clocks_.begin(); it != associated_clocks_.end(); ++it) { - set_clock(last_time_msg_, true, *it); - } + set_all_clocks(last_time_msg_, true); } // An internal method to use in the clock callback that iterates and disables all clocks @@ -71,11 +69,8 @@ class ClocksState final ros_time_active_ = false; // Update all attached clocks - std::lock_guard guard(clock_list_lock_); - for (auto it = associated_clocks_.begin(); it != associated_clocks_.end(); ++it) { - auto msg = std::make_shared(); - set_clock(msg, false, *it); - } + auto msg = std::make_shared(); + set_all_clocks(msg, false); } // Check if ROS time is active