diff --git a/rclcpp/include/rclcpp/executors/events_executor.hpp b/rclcpp/include/rclcpp/executors/events_executor.hpp index ede9eaa4c4..700225c81c 100644 --- a/rclcpp/include/rclcpp/executors/events_executor.hpp +++ b/rclcpp/include/rclcpp/executors/events_executor.hpp @@ -168,11 +168,12 @@ class EventsExecutor : public rclcpp::Executor void execute_event(const ExecutorEvent & event); - // Event queue members + // Event queue std::queue event_queue_; + // Mutex to protect insertion and extraction of events in the queue std::mutex event_queue_mutex_; + // Variable used to notify when an event is added to the queue std::condition_variable event_queue_cv_; - // Timers manager std::shared_ptr timers_manager_; }; diff --git a/rclcpp/include/rclcpp/executors/events_executor_entities_collector.hpp b/rclcpp/include/rclcpp/executors/events_executor_entities_collector.hpp index bd20f6de22..d34e709b35 100644 --- a/rclcpp/include/rclcpp/executors/events_executor_entities_collector.hpp +++ b/rclcpp/include/rclcpp/executors/events_executor_entities_collector.hpp @@ -103,11 +103,9 @@ class EventsExecutorEntitiesCollector final : public rclcpp::Waitable /// List of weak nodes registered in the events executor std::list weak_nodes_; - /// Executor using this entities collector object EventsExecutor * associated_executor_ = nullptr; - - // Instance of the timers manager used by the associated executor + /// Instance of the timers manager used by the associated executor TimersManager::SharedPtr timers_manager_; }; diff --git a/rclcpp/src/rclcpp/executors/events_executor.cpp b/rclcpp/src/rclcpp/executors/events_executor.cpp index 20c99ea751..87c0686a1f 100644 --- a/rclcpp/src/rclcpp/executors/events_executor.cpp +++ b/rclcpp/src/rclcpp/executors/events_executor.cpp @@ -101,6 +101,11 @@ EventsExecutor::spin_some(std::chrono::nanoseconds max_duration) } RCLCPP_SCOPE_EXIT(this->spinning.store(false);); + // In this context a 0 input max_duration means no duration limit + if (std::chrono::nanoseconds(0) == max_duration) { + max_duration = timers_manager_->MAX_TIME; + } + // This function will wait until the first of the following events occur: // - The input max_duration is elapsed // - A timer triggers @@ -230,6 +235,7 @@ void EventsExecutor::add_node( rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr, bool notify) { + // This field is unused because we don't have to wake up the executor when a node is added. (void) notify; // Add node to entities collector @@ -246,6 +252,7 @@ void EventsExecutor::remove_node( rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr, bool notify) { + // This field is unused because we don't have to wake up the executor when a node is removed. (void)notify; // Remove node from entities collector