15 #ifndef RCLCPP__EXECUTORS__EXECUTOR_ENTITIES_COLLECTOR_HPP_
16 #define RCLCPP__EXECUTORS__EXECUTOR_ENTITIES_COLLECTOR_HPP_
24 #include "rcpputils/thread_safety_annotations.hpp"
26 #include <rclcpp/any_executable.hpp>
27 #include <rclcpp/node_interfaces/node_base.hpp>
28 #include <rclcpp/callback_group.hpp>
29 #include <rclcpp/executors/executor_notify_waitable.hpp>
30 #include <rclcpp/visibility_control.hpp>
31 #include <rclcpp/wait_set.hpp>
32 #include <rclcpp/wait_result.hpp>
66 std::shared_ptr<ExecutorNotifyWaitable> notify_waitable);
85 add_node(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr);
95 remove_node(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr);
122 std::vector<rclcpp::CallbackGroup::WeakPtr>
131 std::vector<rclcpp::CallbackGroup::WeakPtr>
140 std::vector<rclcpp::CallbackGroup::WeakPtr>
153 using NodeCollection = std::set<
154 rclcpp::node_interfaces::NodeBaseInterface::WeakPtr,
155 std::owner_less<rclcpp::node_interfaces::NodeBaseInterface::WeakPtr>>;
157 using CallbackGroupCollection = std::set<
158 rclcpp::CallbackGroup::WeakPtr,
159 std::owner_less<rclcpp::CallbackGroup::WeakPtr>>;
161 using WeakNodesToGuardConditionsMap = std::map<
162 rclcpp::node_interfaces::NodeBaseInterface::WeakPtr,
163 rclcpp::GuardCondition::WeakPtr,
164 std::owner_less<rclcpp::node_interfaces::NodeBaseInterface::WeakPtr>>;
166 using WeakGroupsToGuardConditionsMap = std::map<
167 rclcpp::CallbackGroup::WeakPtr,
168 rclcpp::GuardCondition::WeakPtr,
169 std::owner_less<rclcpp::CallbackGroup::WeakPtr>>;
184 NodeCollection::iterator
201 CallbackGroupCollection::iterator
203 CallbackGroupCollection::iterator weak_group_it,
204 CallbackGroupCollection & collection) RCPPUTILS_TSA_REQUIRES(
mutex_);
214 rclcpp::CallbackGroup::SharedPtr group_ptr,
215 CallbackGroupCollection & collection) RCPPUTILS_TSA_REQUIRES(
mutex_);
227 const NodeCollection & nodes_to_check) RCPPUTILS_TSA_REQUIRES(
mutex_);
Class to monitor a set of nodes and callback groups for changes in entity membership.
RCLCPP_PUBLIC NodeCollection::iterator remove_weak_node(NodeCollection::iterator weak_node) RCPPUTILS_TSA_REQUIRES(mutex_)
Implementation of removing a node from the collector.
RCLCPP_PUBLIC void add_node(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr)
Add a node to the entity collector.
RCLCPP_PUBLIC void prune_invalid_nodes_and_groups() RCPPUTILS_TSA_REQUIRES(mutex_)
Check all nodes and group for expired weak pointers and remove them.
std::shared_ptr< ExecutorNotifyWaitable > notify_waitable_
Waitable to add guard conditions to.
CallbackGroupCollection pending_manually_added_groups_ RCPPUTILS_TSA_GUARDED_BY(mutex_)
callback groups that have been added since the last update.
RCLCPP_PUBLIC void update_collections()
Update the underlying collections.
RCLCPP_PUBLIC void remove_callback_group(rclcpp::CallbackGroup::SharedPtr group_ptr)
Remove a callback group from the entity collector.
NodeCollection pending_added_nodes_ RCPPUTILS_TSA_GUARDED_BY(mutex_)
nodes that have been added since the last update.
RCLCPP_PUBLIC std::vector< rclcpp::CallbackGroup::WeakPtr > get_all_callback_groups() const
Get all callback groups known to this entity collector.
bool has_pending() const
Indicate if the entities collector has pending additions or removals.
RCLCPP_PUBLIC void process_queues() RCPPUTILS_TSA_REQUIRES(mutex_)
Iterate over queued added/remove nodes and callback_groups.
NodeCollection weak_nodes_ RCPPUTILS_TSA_GUARDED_BY(mutex_)
nodes that are associated with the executor
RCLCPP_PUBLIC ExecutorEntitiesCollector(std::shared_ptr< ExecutorNotifyWaitable > notify_waitable)
Constructor.
RCLCPP_PUBLIC ~ExecutorEntitiesCollector()
Destructor.
std::mutex mutex_
mutex to protect collections and pending queues
WeakNodesToGuardConditionsMap weak_nodes_to_guard_conditions_ RCPPUTILS_TSA_GUARDED_BY(mutex_)
Track guard conditions associated with added nodes.
WeakGroupsToGuardConditionsMap weak_groups_to_guard_conditions_ RCPPUTILS_TSA_GUARDED_BY(mutex_)
Track guard conditions associated with added callback groups.
RCLCPP_PUBLIC void add_automatically_associated_callback_groups(const NodeCollection &nodes_to_check) RCPPUTILS_TSA_REQUIRES(mutex_)
CallbackGroupCollection manually_added_groups_ RCPPUTILS_TSA_GUARDED_BY(mutex_)
Callback groups that were added via add_callback_group
CallbackGroupCollection pending_manually_removed_groups_ RCPPUTILS_TSA_GUARDED_BY(mutex_)
callback groups that have been removed since the last update.
RCLCPP_PUBLIC std::vector< rclcpp::CallbackGroup::WeakPtr > get_automatically_added_callback_groups() const
Get automatically-added callback groups known to this entity collector.
CallbackGroupCollection automatically_added_groups_ RCPPUTILS_TSA_GUARDED_BY(mutex_)
Callback groups that were added by their association with added nodes.
NodeCollection pending_removed_nodes_ RCPPUTILS_TSA_GUARDED_BY(mutex_)
nodes that have been removed since the last update.
RCLCPP_PUBLIC CallbackGroupCollection::iterator remove_weak_callback_group(CallbackGroupCollection::iterator weak_group_it, CallbackGroupCollection &collection) RCPPUTILS_TSA_REQUIRES(mutex_)
Implementation of removing a callback group from the collector.
RCLCPP_PUBLIC void add_callback_group_to_collection(rclcpp::CallbackGroup::SharedPtr group_ptr, CallbackGroupCollection &collection) RCPPUTILS_TSA_REQUIRES(mutex_)
Implementation of adding a callback group.
RCLCPP_PUBLIC void remove_node(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr)
Remove a node from the entity collector.
RCLCPP_PUBLIC std::vector< rclcpp::CallbackGroup::WeakPtr > get_manually_added_callback_groups() const
Get manually-added callback groups known to this entity collector.
RCLCPP_PUBLIC void add_callback_group(rclcpp::CallbackGroup::SharedPtr group_ptr)
Add a callback group to the entity collector.
Versions of rosidl_typesupport_cpp::get_message_type_support_handle that handle adapted types.