Skip to content

Commit 653d1a3

Browse files
committed
Make executor own the notify waitable
Signed-off-by: Michael Carroll <[email protected]>
1 parent e173e5a commit 653d1a3

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

rclcpp/include/rclcpp/executors/executor_entities_collector.hpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class ExecutorEntitiesCollector
6464
*/
6565
RCLCPP_PUBLIC
6666
explicit ExecutorEntitiesCollector(
67-
std::function<void(void)> on_notify_waitable_callback = {});
67+
std::shared_ptr<ExecutorNotifyWaitable> notify_waitable);
6868

6969
/// Destructor
7070
RCLCPP_PUBLIC
@@ -144,9 +144,6 @@ class ExecutorEntitiesCollector
144144
std::vector<rclcpp::CallbackGroup::WeakPtr>
145145
get_automatically_added_callback_groups();
146146

147-
RCLCPP_PUBLIC
148-
std::shared_ptr<ExecutorNotifyWaitable> get_notify_waitable();
149-
150147
/// Update the underlying collections
151148
/**
152149
* This will prune nodes and callback groups that are no longer valid as well
@@ -225,7 +222,7 @@ class ExecutorEntitiesCollector
225222

226223
WeakGroupsToGuardConditionsMap weak_groups_to_guard_conditions_ RCPPUTILS_TSA_GUARDED_BY(mutex_);
227224

228-
std::shared_ptr<ExecutorNotifyWaitable> notify_waitable_ RCPPUTILS_TSA_GUARDED_BY(mutex_);
225+
std::shared_ptr<ExecutorNotifyWaitable> notify_waitable_;
229226
};
230227
} // namespace executors
231228
} // namespace rclcpp

rclcpp/src/rclcpp/executors/executor_entities_collector.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ namespace executors
2424
{
2525

2626
ExecutorEntitiesCollector::ExecutorEntitiesCollector(
27-
std::function<void(void)> on_notify_waitable_callback)
28-
: notify_waitable_(std::make_shared<ExecutorNotifyWaitable>(on_notify_waitable_callback))
27+
std::shared_ptr<ExecutorNotifyWaitable> notify_waitable)
28+
: notify_waitable_(notify_waitable)
2929
{
3030
}
3131

@@ -152,12 +152,6 @@ ExecutorEntitiesCollector::get_automatically_added_callback_groups()
152152
return groups;
153153
}
154154

155-
std::shared_ptr<ExecutorNotifyWaitable>
156-
ExecutorEntitiesCollector::get_notify_waitable()
157-
{
158-
return this->notify_waitable_;
159-
}
160-
161155
void
162156
ExecutorEntitiesCollector::update_collections()
163157
{

rclcpp/test/rclcpp/executors/test_entities_collector.cpp

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include <gtest/gtest.h>
1616

17+
#include "rclcpp/executors/executor_notify_waitable.hpp"
1718
#include "rclcpp/rclcpp.hpp"
1819
#include "rclcpp/executors/executor_entities_collector.hpp"
1920

@@ -34,7 +35,8 @@ class TestExecutorEntitiesCollector : public ::testing::Test
3435
};
3536

3637
TEST_F(TestExecutorEntitiesCollector, add_remove_node) {
37-
auto entities_collector = rclcpp::executors::ExecutorEntitiesCollector();
38+
auto notify_waitable = std::make_shared<rclcpp::executors::ExecutorNotifyWaitable>();
39+
auto entities_collector = rclcpp::executors::ExecutorEntitiesCollector(notify_waitable);
3840

3941
auto node1 = std::make_shared<rclcpp::Node>("node1", "ns");
4042
auto node2 = std::make_shared<rclcpp::Node>("node2", "ns");
@@ -78,7 +80,8 @@ TEST_F(TestExecutorEntitiesCollector, add_remove_node) {
7880
}
7981

8082
TEST_F(TestExecutorEntitiesCollector, add_callback_group) {
81-
auto entities_collector = rclcpp::executors::ExecutorEntitiesCollector();
83+
auto notify_waitable = std::make_shared<rclcpp::executors::ExecutorNotifyWaitable>();
84+
auto entities_collector = rclcpp::executors::ExecutorEntitiesCollector(notify_waitable);
8285

8386
auto node = std::make_shared<rclcpp::Node>("node1", "ns");
8487
rclcpp::CallbackGroup::SharedPtr cb_group = node->create_callback_group(
@@ -91,7 +94,8 @@ TEST_F(TestExecutorEntitiesCollector, add_callback_group) {
9194
}
9295

9396
TEST_F(TestExecutorEntitiesCollector, add_node_default_callback_group) {
94-
auto entities_collector = rclcpp::executors::ExecutorEntitiesCollector();
97+
auto notify_waitable = std::make_shared<rclcpp::executors::ExecutorNotifyWaitable>();
98+
auto entities_collector = rclcpp::executors::ExecutorEntitiesCollector(notify_waitable);
9599

96100
auto node = std::make_shared<rclcpp::Node>("node1", "ns");
97101
entities_collector.add_node(node->get_node_base_interface());
@@ -102,7 +106,8 @@ TEST_F(TestExecutorEntitiesCollector, add_node_default_callback_group) {
102106
}
103107

104108
TEST_F(TestExecutorEntitiesCollector, add_callback_group_after_add_node) {
105-
auto entities_collector = rclcpp::executors::ExecutorEntitiesCollector();
109+
auto notify_waitable = std::make_shared<rclcpp::executors::ExecutorNotifyWaitable>();
110+
auto entities_collector = rclcpp::executors::ExecutorEntitiesCollector(notify_waitable);
106111

107112
auto node = std::make_shared<rclcpp::Node>("node1", "ns");
108113
rclcpp::CallbackGroup::SharedPtr cb_group = node->create_callback_group(
@@ -115,7 +120,8 @@ TEST_F(TestExecutorEntitiesCollector, add_callback_group_after_add_node) {
115120
}
116121

117122
TEST_F(TestExecutorEntitiesCollector, add_callback_group_twice) {
118-
auto entities_collector = rclcpp::executors::ExecutorEntitiesCollector();
123+
auto notify_waitable = std::make_shared<rclcpp::executors::ExecutorNotifyWaitable>();
124+
auto entities_collector = rclcpp::executors::ExecutorEntitiesCollector(notify_waitable);
119125

120126
auto node = std::make_shared<rclcpp::Node>("node1", "ns");
121127
rclcpp::CallbackGroup::SharedPtr cb_group = node->create_callback_group(
@@ -133,7 +139,8 @@ TEST_F(TestExecutorEntitiesCollector, add_callback_group_twice) {
133139
}
134140

135141
TEST_F(TestExecutorEntitiesCollector, remove_callback_group_after_node) {
136-
auto entities_collector = rclcpp::executors::ExecutorEntitiesCollector();
142+
auto notify_waitable = std::make_shared<rclcpp::executors::ExecutorNotifyWaitable>();
143+
auto entities_collector = rclcpp::executors::ExecutorEntitiesCollector(notify_waitable);
137144

138145
auto node = std::make_shared<rclcpp::Node>("node1", "ns");
139146
rclcpp::CallbackGroup::SharedPtr cb_group = node->create_callback_group(
@@ -154,7 +161,8 @@ TEST_F(TestExecutorEntitiesCollector, remove_callback_group_after_node) {
154161
}
155162

156163
TEST_F(TestExecutorEntitiesCollector, remove_callback_group_twice) {
157-
auto entities_collector = rclcpp::executors::ExecutorEntitiesCollector();
164+
auto notify_waitable = std::make_shared<rclcpp::executors::ExecutorNotifyWaitable>();
165+
auto entities_collector = rclcpp::executors::ExecutorEntitiesCollector(notify_waitable);
158166

159167
auto node = std::make_shared<rclcpp::Node>("node1", "ns");
160168
rclcpp::CallbackGroup::SharedPtr cb_group = node->create_callback_group(
@@ -173,7 +181,8 @@ TEST_F(TestExecutorEntitiesCollector, remove_callback_group_twice) {
173181
}
174182

175183
TEST_F(TestExecutorEntitiesCollector, remove_node_opposite_order) {
176-
auto entities_collector = rclcpp::executors::ExecutorEntitiesCollector();
184+
auto notify_waitable = std::make_shared<rclcpp::executors::ExecutorNotifyWaitable>();
185+
auto entities_collector = rclcpp::executors::ExecutorEntitiesCollector(notify_waitable);
177186

178187
auto node1 = std::make_shared<rclcpp::Node>("node1", "ns");
179188
EXPECT_NO_THROW(entities_collector.add_node(node1->get_node_base_interface()));

0 commit comments

Comments
 (0)