14#ifndef BOOST_FAIRNESS_RECURSIVE_PRIORITY_MUTEX_HPP
15#define BOOST_FAIRNESS_RECURSIVE_PRIORITY_MUTEX_HPP
48 template<
size_t N = 1>
52 using Thread_cnt_t = uint32_t;
117 internalMutex_.lock(priority);
119 ++waiters_[priority];
123 lock_owned_by_me_() ||
124 (find_first_priority_() >= priority &&
128 owner_ = std::this_thread::get_id();
130 --waiters_[priority];
134 internalMutex_.unlock();
139 internalMutex_.unlock();
143 internalMutex_.lock(priority);
188 internalMutex_.lock();
190 p = find_first_priority_();
194 if (recursionCounter_ != 0)
196 internalMutex_.unlock();
201 owner_ = std::thread::id();
205 internalMutex_.unlock();
210 waitingFlag_.reset_(p);
212 internalMutex_.unlock();
266 internalMutex_.lock(priority);
268 if (lock_owned_by_me_() ||
269 (find_first_priority_() >= priority && lock_not_owned_())){
271 owner_ = std::this_thread::get_id();
275 internalMutex_.unlock();
280 internalMutex_.unlock();
291 std::array<Thread_cnt_t, N> waiters_{};
293 std::thread::id owner_{};
295 uint32_t recursionCounter_{};
297 bool lock_not_owned_(){
298 return std::thread::id() == owner_;
301 bool lock_owned_by_me_(){
302 return owner_ == std::this_thread::get_id();
Definition wait_pool.hpp:45
The recursive_priority_mutex is an advanced synchronization mechanism that enhances the traditional m...
Definition recursive_priority_mutex.hpp:50
bool try_lock(Priority_t const priority=0)
Try to acquire the unique ownership of the recursive_priority_mutex with a designated priority....
Definition recursive_priority_mutex.hpp:264
void lock(Priority_t const priority=0)
Acquire the recursive_priority_mutex with a designated priority. If another thread has already obtain...
Definition recursive_priority_mutex.hpp:115
void unlock()
Unlock the recursive_priority_mutex when its ownership level is 1, signifying that there was precisel...
Definition recursive_priority_mutex.hpp:184
The spinlock_priority_mutex is an advanced synchronization mechanism that enhances the traditional mu...
Definition spinlock_priority_mutex_cpl.hpp:31
#define BOOST_FAIRNESS_HARDWARE_DESTRUCTIVE_SIZE
Size to be aligned to avoid false sharing
Definition config.hpp:85
void wait(T &mem, K const expected) noexcept
Definition wait_ops.hpp:69
void notify_one(T &mem) noexcept
Definition wait_ops.hpp:103
Definition acquisition_modes.hpp:16
uint8_t Priority_t
Definition priority_t.hpp:17
#define WAIT
Definition priority_mutex_tatas.hpp:24
Alias the type Priority_t. Priority_t is the type of priorities that are used by the priority_mutexes...
#define BOOST_FAIRNESS_MAXIMUM_PRIORITY
Priorities are indexes in an array, that means that if I define a priority_mutex<BOOST_FAIRNESS_MAXIM...
Definition priority_t.hpp:24
This file contains the implementation of the spinlock_priority_mutex based on a scalable list base al...
This file contains the implementation of the wait operations used by the mutexes.