From 5b6de09cce60e916df2a33dcf98c2c23e991f4af Mon Sep 17 00:00:00 2001 From: Donghee Ye Date: Mon, 23 Mar 2020 11:28:50 +0900 Subject: [PATCH] Apply comment: add spin_once_impl private method Signed-off-by: Donghee Ye --- rclcpp/include/rclcpp/executor.hpp | 9 +++++---- rclcpp/src/rclcpp/executor.cpp | 13 +++++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/rclcpp/include/rclcpp/executor.hpp b/rclcpp/include/rclcpp/executor.hpp index bee3f92d0f..21d3f73dd6 100644 --- a/rclcpp/include/rclcpp/executor.hpp +++ b/rclcpp/include/rclcpp/executor.hpp @@ -251,10 +251,8 @@ class Executor RCLCPP_SCOPE_EXIT(this->spinning.store(false); ); while (rclcpp::ok(this->context_) && spinning.load()) { // Do one item of work. - AnyExecutable any_exec; - if (get_next_executable(any_exec, timeout_left)) { - execute_any_executable(any_exec); - } + spin_once_impl(timeout_left); + // Check if the future is set, return SUCCESS if it is. status = future.wait_for(std::chrono::seconds(0)); if (status == std::future_status::ready) { @@ -368,6 +366,9 @@ class Executor private: RCLCPP_DISABLE_COPY(Executor) + void + spin_once_impl(std::chrono::nanoseconds timeout); + std::list weak_nodes_; std::list guard_conditions_; }; diff --git a/rclcpp/src/rclcpp/executor.cpp b/rclcpp/src/rclcpp/executor.cpp index 3b4d74d598..64aa7f7e15 100644 --- a/rclcpp/src/rclcpp/executor.cpp +++ b/rclcpp/src/rclcpp/executor.cpp @@ -246,6 +246,14 @@ Executor::spin_some(std::chrono::nanoseconds max_duration) } } +void +Executor::spin_once_impl(std::chrono::nanoseconds timeout) { + AnyExecutable any_exec; + if (get_next_executable(any_exec, timeout)) { + execute_any_executable(any_exec); + } +} + void Executor::spin_once(std::chrono::nanoseconds timeout) { @@ -253,10 +261,7 @@ Executor::spin_once(std::chrono::nanoseconds timeout) throw std::runtime_error("spin_once() called while already spinning"); } RCLCPP_SCOPE_EXIT(this->spinning.store(false); ); - AnyExecutable any_exec; - if (get_next_executable(any_exec, timeout)) { - execute_any_executable(any_exec); - } + spin_once_impl(timeout); } void