ROS 2 rclcpp + rcl - kilted  kilted
ROS 2 C++ Client Library with ROS Client Library
static_single_threaded_executor.hpp
1 // Copyright 2019 Nobleo Technology
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef RCLCPP__EXECUTORS__STATIC_SINGLE_THREADED_EXECUTOR_HPP_
16 #define RCLCPP__EXECUTORS__STATIC_SINGLE_THREADED_EXECUTOR_HPP_
17 
18 #include <atomic>
19 #include <chrono>
20 #include <memory>
21 
22 #include "rclcpp/executor.hpp"
23 #include "rclcpp/executors/executor_entities_collection.hpp"
24 #include "rclcpp/executors/single_threaded_executor.hpp"
25 
26 namespace rclcpp
27 {
28 namespace executors
29 {
30 
32 
54  : public rclcpp::Executor
55 {
56 public:
57  RCLCPP_SMART_PTR_DEFINITIONS(StaticSingleThreadedExecutor)
58 
59 
60  RCLCPP_PUBLIC
63 
65  RCLCPP_PUBLIC
67 
69 
74  RCLCPP_PUBLIC
75  void
76  spin() override;
77 
79 
92  RCLCPP_PUBLIC
93  void
94  spin_some(std::chrono::nanoseconds max_duration = std::chrono::nanoseconds(0)) override;
95 
97 
111  RCLCPP_PUBLIC
112  void
113  spin_all(std::chrono::nanoseconds max_duration) override;
114 
115 protected:
123  bool
124  execute_ready_executables(
127  bool spin_once);
128 
129  void
130  spin_some_impl(std::chrono::nanoseconds max_duration, bool exhaustive);
131 
132  void
133  spin_once_impl(std::chrono::nanoseconds timeout) override;
134 
135  std::optional<rclcpp::WaitResult<rclcpp::WaitSet>>
136  collect_and_wait(std::chrono::nanoseconds timeout);
137 
138 private:
139  RCLCPP_DISABLE_COPY(StaticSingleThreadedExecutor)
140 };
141 
142 } // namespace executors
143 } // namespace rclcpp
144 
145 #endif // RCLCPP__EXECUTORS__STATIC_SINGLE_THREADED_EXECUTOR_HPP_
Coordinate the order and timing of available communication tasks.
Definition: executor.hpp:65
Interface for introspecting a wait set after waiting on it.
Definition: wait_result.hpp:63
Single-threaded executor implementation.
Versions of rosidl_typesupport_cpp::get_message_type_support_handle that handle adapted types.
RCLCPP_PUBLIC void spin(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr)
Create a default single-threaded executor and spin the specified node.
Definition: executors.cpp:50
RCLCPP_PUBLIC void spin_all(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr, std::chrono::nanoseconds max_duration)
Create a default single-threaded executor and execute all available work exhaustively.
Definition: executors.cpp:18
RCLCPP_PUBLIC void spin_some(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr)
Create a default single-threaded executor and execute any immediately available work.
Definition: executors.cpp:35
Options to be passed to the executor constructor.
Represent the total set of entities for a single executor.