@@ -49,7 +49,9 @@ class EventsExecutor;
4949 * When this occurs, the execute API takes care of handling changes
5050 * in the entities currently used by the executor.
5151 */
52- class EventsExecutorEntitiesCollector final : public EventWaitable
52+ class EventsExecutorEntitiesCollector final
53+ : public EventWaitable,
54+ public std::enable_shared_from_this<EventsExecutorEntitiesCollector>
5355{
5456public:
5557 RCLCPP_SMART_PTR_DEFINITIONS (EventsExecutorEntitiesCollector)
@@ -63,6 +65,10 @@ class EventsExecutorEntitiesCollector final : public EventWaitable
6365 RCLCPP_PUBLIC
6466 ~EventsExecutorEntitiesCollector ();
6567
68+ // Initialize entities collector
69+ RCLCPP_PUBLIC
70+ void init ();
71+
6672 // The purpose of "execute" is handling the situation of a new entity added to
6773 // a node, while the executor is already spinning.
6874 // This consists in setting that entitiy's callback.
@@ -237,6 +243,8 @@ class EventsExecutorEntitiesCollector final : public EventWaitable
237243 std::list<rclcpp::node_interfaces::NodeBaseInterface::WeakPtr> weak_nodes_;
238244
239245 // Maps: entity identifiers to weak pointers from the entities registered in the executor
246+ // so in the case of an event providing and ID, we can retrieve and own the corresponding
247+ // entity while it performs work
240248 std::unordered_map<const void *, rclcpp::SubscriptionBase::WeakPtr> weak_subscriptions_map_;
241249 std::unordered_map<const void *, rclcpp::ServiceBase::WeakPtr> weak_services_map_;
242250 std::unordered_map<const void *, rclcpp::ClientBase::WeakPtr> weak_clients_map_;
0 commit comments