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

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

#include <sys_mutex.hpp>

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

Public Member Functions

constexpr sys_mutex_ref (native_pointer m) noexcept
 Construct a mutex using a native sys_mutex*. More...
 
template<class T_Mutex >
constexpr sys_mutex_ref (T_Mutex &m) noexcept
 Construct a mutex using a native sys_mutex*. More...
 
constexpr sys_mutex_refoperator= (native_pointer m) noexcept
 Construct a mutex using a native sys_mutex*. More...
 
template<class T_Mutex >
constexpr sys_mutex_refoperator= (T_Mutex &m) noexcept
 Construct a mutex using a native sys_mutex*. 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...
 
 sys_mutex_ref ()=delete
 
- Public Member Functions inherited from zpp::sys_mutex_base< sys_mutex_ref >
 sys_mutex_base (const sys_mutex_base &)=delete
 
 sys_mutex_base (sys_mutex_base &&)=delete
 
bool lock () noexcept
 Lock the mutex. Wait for ever until it is locked. More...
 
bool try_lock () noexcept
 Try locking the mutex without waiting. More...
 
bool try_lock_for (const std::chrono::duration< T_Rep, T_Period > &timeout) noexcept
 Try locking the mutex with a timeout. More...
 
bool 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...
 
sys_mutex_baseoperator= (const sys_mutex_base &)=delete
 
sys_mutex_baseoperator= (sys_mutex_base &&)=delete
 

Additional Inherited Members

- Public Types inherited from zpp::sys_mutex_base< sys_mutex_ref >
using native_type = struct sys_mutex
 
using native_pointer = native_type *
 
using native_cont_pointer = native_type const *
 
- Protected Member Functions inherited from zpp::sys_mutex_base< sys_mutex_ref >
constexpr sys_mutex_base () noexcept=default
 Protected default contructor so only derived objects can be created. More...
 

Detailed Description

A recursive mutex class borrowing the native mutex.

Definition at line 167 of file sys_mutex.hpp.

Constructor & Destructor Documentation

◆ sys_mutex_ref() [1/3]

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

Construct a mutex using a native sys_mutex*.

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

Definition at line 175 of file sys_mutex.hpp.

176  : m_mutex_ptr(m)
177  {
178  __ASSERT_NO_MSG(m_mutex_ptr != nullptr);
179  }

◆ sys_mutex_ref() [2/3]

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

Construct a mutex using a native sys_mutex*.

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

Definition at line 188 of file sys_mutex.hpp.

189  : m_mutex_ptr(m.native_handle())
190  {
191  __ASSERT_NO_MSG(m_mutex_ptr != nullptr);
192  }

◆ sys_mutex_ref() [3/3]

zpp::sys_mutex_ref::sys_mutex_ref ( )
delete

Member Function Documentation

◆ native_handle() [1/2]

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

get the native zephyr mutex handle.

Returns
A pointer to the zephyr sys_mutex.

Definition at line 236 of file sys_mutex.hpp.

237  {
238  return m_mutex_ptr;
239  }

◆ native_handle() [2/2]

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

get the native zephyr mutex handle.

Returns
A pointer to the zephyr sys_mutex.

Definition at line 226 of file sys_mutex.hpp.

227  {
228  return m_mutex_ptr;
229  }

Referenced by operator=().

◆ operator=() [1/2]

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

Construct a mutex using a native sys_mutex*.

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

Definition at line 200 of file sys_mutex.hpp.

201  {
202  m_mutex_ptr = m;
203  __ASSERT_NO_MSG(m_mutex_ptr != nullptr);
204  return *this;
205  }

◆ operator=() [2/2]

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

Construct a mutex using a native sys_mutex*.

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

Definition at line 214 of file sys_mutex.hpp.

215  {
216  m_mutex_ptr = m.native_handle();
217  __ASSERT_NO_MSG(m_mutex_ptr != nullptr);
218  return *this;
219  }
constexpr auto native_handle() noexcept -> native_pointer
get the native zephyr mutex handle.
Definition: sys_mutex.hpp:141

References native_handle().


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