mirror of
https://github.com/micro-ROS/micro-ROS-Agent.git
synced 2026-09-06 09:55:15 +02:00
Add exit to graph manager thread
This commit is contained in:
@@ -80,7 +80,16 @@ public:
|
|||||||
/**
|
/**
|
||||||
* @brief Default destructor.
|
* @brief Default destructor.
|
||||||
*/
|
*/
|
||||||
~GraphManager() = default;
|
~GraphManager()
|
||||||
|
{
|
||||||
|
exit = true;
|
||||||
|
cv_.notify_one();
|
||||||
|
|
||||||
|
if (microros_graph_publisher_.joinable())
|
||||||
|
{
|
||||||
|
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.
|
||||||
@@ -298,6 +307,7 @@ private:
|
|||||||
std::string& node_name,
|
std::string& node_name,
|
||||||
std::string& node_namespace);
|
std::string& node_namespace);
|
||||||
|
|
||||||
|
bool exit = false;
|
||||||
eprosima::fastdds::dds::DomainId_t domain_id_;
|
eprosima::fastdds::dds::DomainId_t domain_id_;
|
||||||
bool graph_changed_;
|
bool graph_changed_;
|
||||||
bool display_on_change_;
|
bool display_on_change_;
|
||||||
|
|||||||
@@ -137,10 +137,15 @@ inline void GraphManager::publish_microros_graph()
|
|||||||
std::unique_lock<std::mutex> lock(mtx_);
|
std::unique_lock<std::mutex> lock(mtx_);
|
||||||
cv_.wait(lock, [this]()
|
cv_.wait(lock, [this]()
|
||||||
{
|
{
|
||||||
return this->graph_changed_;
|
return this->graph_changed_ || exit;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (exit)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (display_on_change_)
|
if (display_on_change_)
|
||||||
{
|
{
|
||||||
std::cout << "Updated uros Graph: graph changed" << std::endl;
|
std::cout << "Updated uros Graph: graph changed" << std::endl;
|
||||||
|
|||||||
Reference in New Issue
Block a user