rclcpp  beta1
C++ ROS Client Library API
multi_threaded_executor.hpp
Go to the documentation of this file.
1 // Copyright 2014 Open Source Robotics Foundation, Inc.
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__MULTI_THREADED_EXECUTOR_HPP_
16 #define RCLCPP__EXECUTORS__MULTI_THREADED_EXECUTOR_HPP_
17 
18 #include <mutex>
19 #include <thread>
20 #include <unordered_map>
21 
22 #include "rclcpp/executor.hpp"
23 #include "rclcpp/macros.hpp"
26 
27 namespace rclcpp
28 {
29 namespace executors
30 {
31 namespace multi_threaded_executor
32 {
33 
35 {
36 public:
38 
41  const executor::ExecutorArgs & args = rclcpp::executor::create_default_executor_arguments());
42 
44  virtual ~MultiThreadedExecutor();
45 
47  void
48  spin();
49 
51  size_t
53 
54 protected:
56  void
57  run(size_t this_thread_number);
58 
59 private:
60  RCLCPP_DISABLE_COPY(MultiThreadedExecutor)
61 
62  std::mutex wait_mutex_;
63  size_t number_of_threads_;
64 };
65 
66 } // namespace multi_threaded_executor
67 } // namespace executors
68 } // namespace rclcpp
69 
70 #endif // RCLCPP__EXECUTORS__MULTI_THREADED_EXECUTOR_HPP_
void spin()
Do work periodically as it becomes available to us. Blocking call, may block indefinitely.
Definition: executor.hpp:69
#define RCLCPP_DISABLE_COPY(...)
Definition: macros.hpp:26
Definition: allocator_common.hpp:24
MultiThreadedExecutor(const executor::ExecutorArgs &args=rclcpp::executor::create_default_executor_arguments())
#define RCLCPP_SMART_PTR_DEFINITIONS(...)
Definition: macros.hpp:36
Coordinate the order and timing of available communication tasks.
Definition: executor.hpp:93
#define RCLCPP_PUBLIC
Definition: visibility_control.hpp:50