From 741dddb181b01f3ce9cabdedc788c0d56f28cedc Mon Sep 17 00:00:00 2001 From: Joshua Wallace Date: Wed, 25 Nov 2026 11:48:52 -0500 Subject: [PATCH] prune expired callback groups Signed-off-by: Joshua Wallace --- rclcpp/src/rclcpp/node_interfaces/node_base.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/rclcpp/src/rclcpp/node_interfaces/node_base.cpp b/rclcpp/src/rclcpp/node_interfaces/node_base.cpp index ba364652a3..73a21c7b32 100644 --- a/rclcpp/src/rclcpp/node_interfaces/node_base.cpp +++ b/rclcpp/src/rclcpp/node_interfaces/node_base.cpp @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include #include #include #include @@ -224,6 +225,12 @@ NodeBase::create_callback_group( automatically_add_to_executor_with_node); std::lock_guard lock(callback_groups_mutex_); callback_groups_.push_back(group); + callback_groups_.erase( + std::remove_if( + callback_groups_.begin(), + callback_groups_.end(), + [](const rclcpp::CallbackGroup::WeakPtr & x) {return x.expired();}), + callback_groups_.end()); // This guard condition is generally used to signal to this node's executor that a callback // group has been added that should be considered for new entities.