zpp
Zephyr C++20 Framework
zpp::mutex_ref Class Reference

A recursive mutex class borrowing the native mutex. More...

#include <mutex.hpp>

Inheritance diagram for zpp::mutex_ref:
[legend]
Collaboration diagram for zpp::mutex_ref:
[legend]

Public Member Functions

constexpr mutex_ref (native_pointer m) noexcept
 Construct a mutex using a native k_mutex*. More...
 
template<class T_Mutex >
constexpr mutex_ref (T_Mutex &m) noexcept
 Construct a mutex using another mutex object. More...
 
constexpr mutex_refoperator= (native_pointer m) noexcept
 Assing another mutex object. More...
 
template<class T_Mutex >
constexpr mutex_refoperator= (T_Mutex &m) noexcept
 Assing another mutex object. More...
 
constexpr auto native_handle () noexcept -> native_pointer
 get the native zephyr mutex handle. More...
 
constexpr auto native_handle () const noexcept -> native_const_pointer
 get the native zephyr mutex handle. More...
 
 mutex_ref ()=delete
 
- Public Member Functions inherited from zpp::mutex_base< mutex_ref >
 mutex_base (const mutex_base &)=delete
 
 mutex_base (mutex_base &&)=delete
 
auto lock () noexcept
 Lock the mutex. Wait forever until it is locked. More...
 
auto try_lock () noexcept
 Try locking the mutex without waiting. More...
 
auto try_lock_for (const std::chrono::duration< T_Rep, T_Period > &timeout) noexcept
 Try locking the mutex with a timeout. More...
 
auto unlock () noexcept
 Unlock the mutex. More...
 
auto native_handle () noexcept -> native_pointer
 get the native zephyr mutex handle. More...
 
auto native_handle () const noexcept -> native_const_pointer
 get the native zephyr mutex handle. More...
 
mutex_baseoperator= (const mutex_base &)=delete
 
mutex_baseoperator= (mutex_base &&)=delete
 

Additional Inherited Members

- Public Types inherited from zpp::mutex_base< mutex_ref >
using native_type = struct k_mutex
 
using native_pointer = native_type *
 
using native_const_pointer = native_type const *
 
- Protected Member Functions inherited from zpp::mutex_base< mutex_ref >
constexpr mutex_base () noexcept
 Protected default constructor so only derived objects can be created. More...
 

Detailed Description

A recursive mutex class borrowing the native mutex.

Definition at line 191 of file mutex.hpp.

Constructor & Destructor Documentation

◆ mutex_ref() [1/3]

constexpr zpp::mutex_ref::mutex_ref ( native_pointer  m)
inlineexplicitconstexprnoexcept

Construct a mutex using a native k_mutex*.

Parameters
mThe k_mutex to use. m must already be initialized and will not be freed.

Definition at line 199 of file mutex.hpp.

200  : m_mutex_ptr(m)
201  {
202  __ASSERT_NO_MSG(m_mutex_ptr != nullptr);
203  }

◆ mutex_ref() [2/3]

template<class T_Mutex >
constexpr zpp::mutex_ref::mutex_ref ( T_Mutex &  m)
inlineexplicitconstexprnoexcept

Construct a mutex using another mutex object.

Parameters
mThe mutex object to use. m must already be initialized and will not be freed.

Definition at line 212 of file mutex.hpp.

213  : m_mutex_ptr(m.native_handle())
214  {
215  __ASSERT_NO_MSG(m_mutex_ptr != nullptr);
216  }

◆ mutex_ref() [3/3]

zpp::mutex_ref::mutex_ref ( )
delete

Member Function Documentation

◆ native_handle() [1/2]

constexpr auto zpp::mutex_ref::native_handle ( ) const -> native_const_pointer
inlineconstexprnoexcept

get the native zephyr mutex handle.

Returns
A pointer to the zephyr k_mutex.

Definition at line 264 of file mutex.hpp.

265  {
266  return m_mutex_ptr;
267  }

◆ native_handle() [2/2]

constexpr auto zpp::mutex_ref::native_handle ( ) -> native_pointer
inlineconstexprnoexcept

get the native zephyr mutex handle.

Returns
A pointer to the zephyr k_mutex.

Definition at line 254 of file mutex.hpp.

255  {
256  return m_mutex_ptr;
257  }

Referenced by operator=().

◆ operator=() [1/2]

constexpr mutex_ref& zpp::mutex_ref::operator= ( native_pointer  m)
inlineconstexprnoexcept

Assing another mutex object.

Parameters
mThe k_mutex to use. m must already be initialized and will not be freed.
Returns
reference to this object

Definition at line 226 of file mutex.hpp.

227  {
228  m_mutex_ptr = m;
229  __ASSERT_NO_MSG(m_mutex_ptr != nullptr);
230  return *this;
231  }

◆ operator=() [2/2]

template<class T_Mutex >
constexpr mutex_ref& zpp::mutex_ref::operator= ( T_Mutex &  m)
inlineconstexprnoexcept

Assing another mutex object.

Parameters
mThe mutex object to use. m must already be initialized and will not be freed.
Returns
reference to this object

Definition at line 242 of file mutex.hpp.

243  {
244  m_mutex_ptr = m.native_handle();
245  __ASSERT_NO_MSG(m_mutex_ptr != nullptr);
246  return *this;
247  }

References native_handle().


The documentation for this class was generated from the following file: