Keep graph manager alive until destruction

This commit is contained in:
Antonio cuadros
2021-07-28 10:01:55 +02:00
parent 1b606c7e92
commit a86d883128
2 changed files with 10 additions and 20 deletions
@@ -80,17 +80,15 @@ public:
/** /**
* @brief Default destructor. * @brief Default destructor.
*/ */
~GraphManager() = default; ~GraphManager()
{
void stop() if (microros_graph_publisher_.joinable())
{ {
if (microros_graph_publisher_.joinable()) exit = true;
{ cv_.notify_one();
exit = true; microros_graph_publisher_.join();
cv_.notify_one(); }
microros_graph_publisher_.join(); }
}
}
/** /**
* @brief Implementation of the notification logic that updates the micro-ROS graph. * @brief Implementation of the notification logic that updates the micro-ROS graph.
+1 -9
View File
@@ -188,19 +188,11 @@ void Agent::run()
void Agent::stop() void Agent::stop()
{ {
xrce_dds_agent_instance_.stop(); xrce_dds_agent_instance_.stop();
for (auto & element : graph_manager_map_)
{
element.second.stop();
}
graph_manager_map_.clear();
} }
graph_manager::GraphManager* Agent::find_or_create_graph_manager(eprosima::fastdds::dds::DomainId_t domain_id) graph_manager::GraphManager* Agent::find_or_create_graph_manager(eprosima::fastdds::dds::DomainId_t domain_id)
{ {
auto it = graph_manager_map_.find(domain_id);
auto it = graph_manager_map_.find(domain_id);
if (it != graph_manager_map_.end()) { if (it != graph_manager_map_.end()) {
return &it->second; return &it->second;