ROS 2 rclcpp + rcl - jazzy  jazzy
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 
48 {
49 public:
50  RCLCPP_SMART_PTR_DEFINITIONS(StaticSingleThreadedExecutor)
51 
52 
53  RCLCPP_PUBLIC
56 
58  RCLCPP_PUBLIC
60 
62 
67  RCLCPP_PUBLIC
68  void
69  spin() override;
70 
72 
85  RCLCPP_PUBLIC
86  void
87  spin_some(std::chrono::nanoseconds max_duration = std::chrono::nanoseconds(0)) override;
88 
90 
104  RCLCPP_PUBLIC
105  void
106  spin_all(std::chrono::nanoseconds max_duration) override;
107 
108 protected:
116  bool
120  bool spin_once);
121 
122  void
123  spin_some_impl(std::chrono::nanoseconds max_duration, bool exhaustive);
124 
125  void
126  spin_once_impl(std::chrono::nanoseconds timeout) override;
127 
128  std::optional<rclcpp::WaitResult<rclcpp::WaitSet>>
129  collect_and_wait(std::chrono::nanoseconds timeout);
130 
131 private:
132  RCLCPP_DISABLE_COPY(StaticSingleThreadedExecutor)
133 };
134 
135 } // namespace executors
136 } // namespace rclcpp
137 
138 #endif // RCLCPP__EXECUTORS__STATIC_SINGLE_THREADED_EXECUTOR_HPP_
Coordinate the order and timing of available communication tasks.
Definition: executor.hpp:65
virtual RCLCPP_PUBLIC void spin_once(std::chrono::nanoseconds timeout=std::chrono::nanoseconds(-1))
Collect work once and execute the next available work, optionally within a duration.
Definition: executor.cpp:446
Interface for introspecting a wait set after waiting on it.
Definition: wait_result.hpp:63
RCLCPP_PUBLIC void spin_some(std::chrono::nanoseconds max_duration=std::chrono::nanoseconds(0)) override
Static executor implementation of spin some.
RCLCPP_PUBLIC void spin() override
Static executor implementation of spin.
virtual RCLCPP_PUBLIC ~StaticSingleThreadedExecutor()
Default destructor.
RCLCPP_PUBLIC void spin_all(std::chrono::nanoseconds max_duration) override
Static executor implementation of spin all.
bool execute_ready_executables(const rclcpp::executors::ExecutorEntitiesCollection &collection, rclcpp::WaitResult< rclcpp::WaitSet > &wait_result, bool spin_once)
Executes ready executables from wait set.
RCLCPP_PUBLIC StaticSingleThreadedExecutor(const rclcpp::ExecutorOptions &options=rclcpp::ExecutorOptions())
Default constructor. See the default constructor for Executor.
Versions of rosidl_typesupport_cpp::get_message_type_support_handle that handle adapted types.
Options to be passed to the executor constructor.
Represent the total set of entities for a single executor.