Skip to content

Commit

Permalink
Merge pull request ros2#17 from alsora/asoragna/minor-clean
Browse files Browse the repository at this point in the history
minor cleanup of comments and spin_some timeout
  • Loading branch information
iRobot ROS authored Oct 15, 2020
2 parents aaaa265 + a77ecdb commit 719ff15
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
5 changes: 3 additions & 2 deletions rclcpp/include/rclcpp/executors/events_executor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,12 @@ class EventsExecutor : public rclcpp::Executor
void
execute_event(const ExecutorEvent & event);

// Event queue members
// Event queue
std::queue<ExecutorEvent> 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<TimersManager> timers_manager_;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,9 @@ class EventsExecutorEntitiesCollector final : public rclcpp::Waitable

/// List of weak nodes registered in the events executor
std::list<rclcpp::node_interfaces::NodeBaseInterface::WeakPtr> 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_;
};

Expand Down
7 changes: 7 additions & 0 deletions rclcpp/src/rclcpp/executors/events_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 719ff15

Please sign in to comment.