Commit 91d0e85 1 parent 49231bc commit 91d0e85 Copy full SHA for 91d0e85
File tree 2 files changed +9
-8
lines changed
common/autoware_universe_utils
include/autoware/universe_utils/system
2 files changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -67,9 +67,9 @@ class ProcessingTimeNode : public std::enable_shared_from_this<ProcessingTimeNod
67
67
/* *
68
68
* @brief Get the parent node
69
69
*
70
- * @return std::shared_ptr <ProcessingTimeNode> Shared pointer to the parent node
70
+ * @return std::weak_ptr <ProcessingTimeNode> Weak pointer to the parent node
71
71
*/
72
- std::shared_ptr <ProcessingTimeNode> get_parent_node () const ;
72
+ std::weak_ptr <ProcessingTimeNode> get_parent_node () const ;
73
73
74
74
/* *
75
75
* @brief Get the child nodes
@@ -94,9 +94,10 @@ class ProcessingTimeNode : public std::enable_shared_from_this<ProcessingTimeNod
94
94
std::string get_name () const ;
95
95
96
96
private:
97
- const std::string name_; // !< Name of the node
98
- double processing_time_{0.0 }; // !< Processing time of the node
99
- std::shared_ptr<ProcessingTimeNode> parent_node_{nullptr }; // !< Shared pointer to the parent node
97
+ const std::string name_; // !< Name of the node
98
+ double processing_time_{0.0 }; // !< Processing time of the node
99
+ std::string comment_; // !< Comment for the node
100
+ std::weak_ptr<ProcessingTimeNode> parent_node_; // !< Weak pointer to the parent node
100
101
std::vector<std::shared_ptr<ProcessingTimeNode>>
101
102
child_nodes_; // !< Vector of shared pointers to the child nodes
102
103
};
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ ProcessingTimeNode::ProcessingTimeNode(const std::string & name) : name_(name)
28
28
std::shared_ptr<ProcessingTimeNode> ProcessingTimeNode::add_child (const std::string & name)
29
29
{
30
30
auto new_child_node = std::make_shared<ProcessingTimeNode>(name);
31
- new_child_node->parent_node_ = shared_from_this ();
31
+ new_child_node->parent_node_ = weak_from_this ();
32
32
child_nodes_.push_back (new_child_node);
33
33
return new_child_node;
34
34
}
@@ -81,7 +81,7 @@ tier4_debug_msgs::msg::ProcessingTimeTree ProcessingTimeNode::to_msg() const
81
81
return time_tree_msg;
82
82
}
83
83
84
- std::shared_ptr <ProcessingTimeNode> ProcessingTimeNode::get_parent_node () const
84
+ std::weak_ptr <ProcessingTimeNode> ProcessingTimeNode::get_parent_node () const
85
85
{
86
86
return parent_node_;
87
87
}
@@ -133,7 +133,7 @@ void TimeKeeper::end_track(const std::string & func_name)
133
133
}
134
134
const double processing_time = stop_watch_.toc (func_name);
135
135
current_time_node_->set_time (processing_time);
136
- current_time_node_ = current_time_node_->get_parent_node ();
136
+ current_time_node_ = current_time_node_->get_parent_node (). lock () ;
137
137
138
138
if (current_time_node_ == nullptr ) {
139
139
report ();
You can’t perform that action at this time.
0 commit comments