rclcpp  master
C++ ROS Client Library API
mutex_two_priorities.hpp
Go to the documentation of this file.
1 // Copyright 2021 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__DETAIL__MUTEX_TWO_PRIORITIES_HPP_
16 #define RCLCPP__DETAIL__MUTEX_TWO_PRIORITIES_HPP_
17 
18 #include <condition_variable>
19 #include <mutex>
20 
21 namespace rclcpp
22 {
23 namespace detail
24 {
26 
31 {
32 public:
34  {
35 public:
36  explicit HighPriorityLockable(MutexTwoPriorities & parent);
37 
38  void lock();
39 
40  void unlock();
41 
42 private:
43  MutexTwoPriorities & parent_;
44  };
45 
47  {
48 public:
49  explicit LowPriorityLockable(MutexTwoPriorities & parent);
50 
51  void lock();
52 
53  void unlock();
54 
55 private:
56  MutexTwoPriorities & parent_;
57  };
58 
61 
64 
65 private:
68  std::mutex cv_mutex_;
69  size_t hp_waiting_count_{0u};
70  bool data_taken_{false};
71 };
72 
73 } // namespace detail
74 } // namespace rclcpp
75 
76 #endif // RCLCPP__DETAIL__MUTEX_TWO_PRIORITIES_HPP_
rclcpp::detail::MutexTwoPriorities::HighPriorityLockable::unlock
void unlock()
rclcpp::detail::MutexTwoPriorities::HighPriorityLockable::HighPriorityLockable
HighPriorityLockable(MutexTwoPriorities &parent)
rclcpp::detail::MutexTwoPriorities::HighPriorityLockable
Definition: mutex_two_priorities.hpp:33
rclcpp
This header provides the get_node_base_interface() template function.
Definition: allocator_common.hpp:24
rclcpp::detail::MutexTwoPriorities::LowPriorityLockable::unlock
void unlock()
rclcpp::detail::MutexTwoPriorities::LowPriorityLockable::LowPriorityLockable
LowPriorityLockable(MutexTwoPriorities &parent)
rclcpp::detail::MutexTwoPriorities::LowPriorityLockable
Definition: mutex_two_priorities.hpp:46
rclcpp::detail::MutexTwoPriorities::get_high_priority_lockable
HighPriorityLockable get_high_priority_lockable()
rclcpp::detail::MutexTwoPriorities
Definition: mutex_two_priorities.hpp:30
std::condition_variable
rclcpp::detail::MutexTwoPriorities::HighPriorityLockable::lock
void lock()
std::mutex
rclcpp::detail::MutexTwoPriorities::get_low_priority_lockable
LowPriorityLockable get_low_priority_lockable()
rclcpp::detail::MutexTwoPriorities::LowPriorityLockable::lock
void lock()