rclcpp  master
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 
33 {
34 public:
36 
39  const executor::ExecutorArgs & args = rclcpp::executor::create_default_executor_arguments());
40 
42  virtual ~MultiThreadedExecutor();
43 
45  void
46  spin();
47 
49  size_t
51 
52 protected:
54  void
55  run(size_t this_thread_number);
56 
57 private:
59 
60  std::mutex wait_mutex_;
61  size_t number_of_threads_;
62 };
63 
64 } // namespace executors
65 } // namespace rclcpp
66 
67 #endif // RCLCPP__EXECUTORS__MULTI_THREADED_EXECUTOR_HPP_
Definition: executor.hpp:66
#define RCLCPP_DISABLE_COPY(...)
Definition: macros.hpp:26
Definition: allocator_common.hpp:24
MultiThreadedExecutor(const executor::ExecutorArgs &args=rclcpp::executor::create_default_executor_arguments())
void run(size_t this_thread_number)
#define RCLCPP_SMART_PTR_DEFINITIONS(...)
Definition: macros.hpp:36
Coordinate the order and timing of available communication tasks.
Definition: executor.hpp:90
void spin()
Do work periodically as it becomes available to us. Blocking call, may block indefinitely.
#define RCLCPP_PUBLIC
Definition: visibility_control.hpp:50
Definition: multi_threaded_executor.hpp:32