.. _program_listing_file_include_rclcpp_executors.hpp: Program Listing for File executors.hpp ====================================== |exhale_lsh| :ref:`Return to documentation for file ` (``include/rclcpp/executors.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp // Copyright 2014 Open Source Robotics Foundation, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef RCLCPP__EXECUTORS_HPP_ #define RCLCPP__EXECUTORS_HPP_ #include #include #include "rclcpp/executors/multi_threaded_executor.hpp" #include "rclcpp/executors/single_threaded_executor.hpp" #include "rclcpp/executors/static_single_threaded_executor.hpp" #include "rclcpp/node.hpp" #include "rclcpp/utilities.hpp" #include "rclcpp/visibility_control.hpp" namespace rclcpp { RCLCPP_PUBLIC void spin_some(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr); RCLCPP_PUBLIC void spin_some(rclcpp::Node::SharedPtr node_ptr); RCLCPP_PUBLIC void spin(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr); RCLCPP_PUBLIC void spin(rclcpp::Node::SharedPtr node_ptr); namespace executors { using rclcpp::executors::MultiThreadedExecutor; using rclcpp::executors::SingleThreadedExecutor; template rclcpp::FutureReturnCode spin_node_until_future_complete( rclcpp::Executor & executor, rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr, const FutureT & future, std::chrono::duration timeout = std::chrono::duration(-1)) { // TODO(wjwwood): does not work recursively; can't call spin_node_until_future_complete // inside a callback executed by an executor. executor.add_node(node_ptr); auto retcode = executor.spin_until_future_complete(future, timeout); executor.remove_node(node_ptr); return retcode; } template rclcpp::FutureReturnCode spin_node_until_future_complete( rclcpp::Executor & executor, std::shared_ptr node_ptr, const FutureT & future, std::chrono::duration timeout = std::chrono::duration(-1)) { return rclcpp::executors::spin_node_until_future_complete( executor, node_ptr->get_node_base_interface(), future, timeout); } } // namespace executors template rclcpp::FutureReturnCode spin_until_future_complete( rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr, const FutureT & future, std::chrono::duration timeout = std::chrono::duration(-1)) { rclcpp::executors::SingleThreadedExecutor executor; return executors::spin_node_until_future_complete(executor, node_ptr, future, timeout); } template rclcpp::FutureReturnCode spin_until_future_complete( std::shared_ptr node_ptr, const FutureT & future, std::chrono::duration timeout = std::chrono::duration(-1)) { return rclcpp::spin_until_future_complete(node_ptr->get_node_base_interface(), future, timeout); } } // namespace rclcpp #endif // RCLCPP__EXECUTORS_HPP_