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

A class using a reference to another native condition variable or zpp::condition_variable. More...

#include <condition_variable.hpp>

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

Public Member Functions

constexpr condition_variable_ref (native_pointer cv) noexcept
 Construct a condition variable using a native k_condvar*. More...
 
template<class T_ContitionVariable >
constexpr condition_variable_ref (const T_ContitionVariable &cv) noexcept
 Construct a condition variable using another condition variable. More...
 
condition_variable_refoperator= (native_pointer cv) noexcept
 copy a condition variable using another condition variable More...
 
template<class T_ContitionVariable >
condition_variable_refoperator= (const T_ContitionVariable &cv) noexcept
 copy a condition variable using another condition variable More...
 
constexpr auto native_handle () noexcept -> native_pointer
 get the native zephyr condition variable handle. More...
 
constexpr auto native_handle () const noexcept -> native_const_pointer
 get the native zephyr condition variable handle. More...
 
- Public Member Functions inherited from zpp::condition_variable_base< condition_variable_ref >
 condition_variable_base (const condition_variable_base &)=delete
 
 condition_variable_base (condition_variable_base &&)=delete
 
auto notify_one () noexcept
 Notify one waiter. More...
 
auto notify_all () noexcept
 Notify all waiters. More...
 
auto wait (T_Mutex &m) noexcept
 wait for ever until the variable is signaled. More...
 
auto wait (T_Mutex &m, T_Predecate pred) noexcept
 wait for ever until the variable is signaled. More...
 
auto try_wait_for (T_Mutex &m, const std::chrono::duration< T_Rep, T_Period > &timeout) noexcept
 Try waiting with a timeout to see if the variable is signaled. More...
 
auto try_wait_for (T_Mutex &m, const std::chrono::duration< T_Rep, T_Period > &timeout, T_Predecate pred) noexcept
 Try waiting with a timeout to see if the variable is signaled. More...
 
auto native_handle () noexcept -> native_pointer
 get the native zephyr k_condvar pointer. More...
 
auto native_handle () const noexcept -> native_const_pointer
 get the native zephyr k_condvar pointer. More...
 
condition_variable_baseoperator= (const condition_variable_base &)=delete
 
condition_variable_baseoperator= (condition_variable_base &&)=delete
 

Additional Inherited Members

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

Detailed Description

A class using a reference to another native condition variable or zpp::condition_variable.

Warning
The condition variable that is referenced must be valid for the lifetime of this object.

Definition at line 278 of file condition_variable.hpp.

Constructor & Destructor Documentation

◆ condition_variable_ref() [1/2]

constexpr zpp::condition_variable_ref::condition_variable_ref ( native_pointer  cv)
inlineexplicitconstexprnoexcept

Construct a condition variable using a native k_condvar*.

Parameters
cvThe k_condvar to use. cv must already be initialized and will not be freed.
Warning
cv must be valid for the lifetime of this object.

Definition at line 289 of file condition_variable.hpp.

290  : m_condvar_ptr(cv)
291  {
292  __ASSERT_NO_MSG(m_condvar_ptr != nullptr);
293  }

◆ condition_variable_ref() [2/2]

template<class T_ContitionVariable >
constexpr zpp::condition_variable_ref::condition_variable_ref ( const T_ContitionVariable &  cv)
inlineexplicitconstexprnoexcept

Construct a condition variable using another condition variable.

Parameters
cvThe condition variable to reference to. cv must already be initialized and will not be freed.
Warning
cv must be valid for the lifetime of this object.

Definition at line 304 of file condition_variable.hpp.

305  : m_condvar_ptr(cv.native_handle())
306  {
307  __ASSERT_NO_MSG(m_condvar_ptr != nullptr);
308  }

Member Function Documentation

◆ native_handle() [1/2]

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

get the native zephyr condition variable handle.

Returns
A pointer to the zephyr k_condvar pointer.

Definition at line 358 of file condition_variable.hpp.

359  {
360  __ASSERT_NO_MSG(m_condvar_ptr != nullptr);
361 
362  return m_condvar_ptr;
363  }

◆ native_handle() [2/2]

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

get the native zephyr condition variable handle.

Returns
A pointer to the zephyr k_condvar pointer.

Definition at line 346 of file condition_variable.hpp.

347  {
348  __ASSERT_NO_MSG(m_condvar_ptr != nullptr);
349 
350  return m_condvar_ptr;
351  }

Referenced by operator=().

◆ operator=() [1/2]

template<class T_ContitionVariable >
condition_variable_ref& zpp::condition_variable_ref::operator= ( const T_ContitionVariable &  cv)
inlinenoexcept

copy a condition variable using another condition variable

Parameters
cvThe condition variable to reference to. cv must already be initialized and will not be freed.
Warning
cv must be valid for the lifetime of this object.

Definition at line 334 of file condition_variable.hpp.

335  {
336  m_condvar_ptr = cv.native_handle();
337  __ASSERT_NO_MSG(m_condvar_ptr != nullptr);
338  return *this;
339  }

References native_handle().

◆ operator=() [2/2]

condition_variable_ref& zpp::condition_variable_ref::operator= ( native_pointer  cv)
inlinenoexcept

copy a condition variable using another condition variable

Parameters
cvThe condition variable to reference to. cv must already be initialized and will not be freed.
Warning
cv must be valid for the lifetime of this object.

Definition at line 318 of file condition_variable.hpp.

319  {
320  m_condvar_ptr = cv;
321  __ASSERT_NO_MSG(m_condvar_ptr != nullptr);
322  return *this;
323  }

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