Skip to content

Commit 6a99496

Browse files
committed
rework events executor constructor
Signed-off-by: Alberto Soragna <[email protected]>
1 parent 191f47a commit 6a99496

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

rclcpp/src/rclcpp/executors/events_executor.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,27 @@ EventsExecutor::EventsExecutor(
3030
const rclcpp::ExecutorOptions & options)
3131
: rclcpp::Executor(options)
3232
{
33+
// Get ownership of the queue used to store events.
34+
if (!events_queue) {
35+
throw std::invalid_argument("events_queue can't be a null pointer");
36+
}
37+
events_queue_ = std::move(events_queue);
38+
events_queue_->init();
39+
40+
// Create timers manager
3341
timers_manager_ = std::make_shared<TimersManager>(context_);
42+
43+
// Create entities collector
3444
entities_collector_ = std::make_shared<EventsExecutorEntitiesCollector>(this);
3545
entities_collector_->init();
3646

37-
3847
// Setup the executor notifier to wake up the executor when some guard conditions are tiggered.
3948
// The added guard conditions are guaranteed to not go out of scope before the executor itself.
4049
executor_notifier_ = std::make_shared<EventsExecutorNotifyWaitable>();
4150
executor_notifier_->add_guard_condition(&shutdown_guard_condition_->get_rcl_guard_condition());
4251
executor_notifier_->add_guard_condition(&interrupt_guard_condition_);
4352
executor_notifier_->set_events_executor_callback(this, &EventsExecutor::push_event);
4453
entities_collector_->add_waitable(executor_notifier_);
45-
46-
// Get ownership of the queue used to store events.
47-
events_queue_ = std::move(events_queue);
48-
// Init the events queue
49-
events_queue_->init();
5054
}
5155

5256
void

0 commit comments

Comments
 (0)