zpp
Zephyr C++20 Framework
|
Counting semaphore base class. More...
#include <sem.hpp>
Public Types | |
using | native_type = struct k_sem |
using | native_pointer = native_type * |
using | native_const_pointer = native_type const * |
using | counter_type = uint32_t |
Type used as counter. More... | |
Public Member Functions | |
bool | take () noexcept |
Take the semaphore waiting forever. More... | |
bool | try_take () noexcept |
Try to take the semaphore without waiting. More... | |
template<class T_Rep , class T_Period > | |
bool | try_take_for (const std::chrono::duration< T_Rep, T_Period > &timeout_duration) noexcept |
Try to take the semaphore waiting a certain timeout. More... | |
void | give () noexcept |
Give the semaphore. More... | |
void | reset () noexcept |
Reset the semaphore counter to zero. More... | |
counter_type | count () noexcept |
Get current semaphore count. More... | |
void | operator++ (int) noexcept |
Give the semaphore. More... | |
void | operator-- (int) noexcept |
Take the semaphore waiting forever. More... | |
void | operator+= (int n) noexcept |
Give the semaphore n times. More... | |
void | operator-= (int n) noexcept |
Take the semaphore n times, waiting forever. More... | |
auto | native_handle () noexcept -> native_pointer |
get the native zephyr sem handle. More... | |
auto | native_handle () const noexcept -> native_const_pointer |
get the native zephyr sem handle. More... | |
sem_base (const sem_base &)=delete | |
sem_base (sem_base &&)=delete | |
sem_base & | operator= (const sem_base &)=delete |
sem_base & | operator= (sem_base &&)=delete |
Static Public Attributes | |
constexpr static counter_type | max_count |
Maximum value of the counter. More... | |
Protected Member Functions | |
constexpr | sem_base () noexcept |
Default constructor, only allowed derived objects. More... | |
Counting semaphore base class.
using zpp::sem_base< T_Sem >::counter_type = uint32_t |
using zpp::sem_base< T_Sem >::native_const_pointer = native_type const * |
using zpp::sem_base< T_Sem >::native_pointer = native_type* |
using zpp::sem_base< T_Sem >::native_type = struct k_sem |
|
inlineconstexprprotectednoexcept |
|
delete |
|
delete |
|
inlinenoexcept |
Get current semaphore count.
Definition at line 117 of file sem.hpp.
References zpp::sem_base< T_Sem >::native_handle().
|
inlinenoexcept |
Give the semaphore.
Definition at line 99 of file sem.hpp.
References zpp::sem_base< T_Sem >::native_handle().
Referenced by zpp::sem_base< T_Sem >::operator++(), and zpp::sem_base< T_Sem >::operator+=().
|
inlinenoexcept |
get the native zephyr sem handle.
Definition at line 181 of file sem.hpp.
References zpp::sem_base< T_Sem >::native_handle().
|
inlinenoexcept |
get the native zephyr sem handle.
Definition at line 171 of file sem.hpp.
Referenced by zpp::sem_base< T_Sem >::count(), zpp::sem_base< T_Sem >::give(), zpp::sem_base< T_Sem >::native_handle(), zpp::sem_base< T_Sem >::reset(), zpp::sem_base< T_Sem >::take(), zpp::sem_base< T_Sem >::try_take(), and zpp::sem_base< T_Sem >::try_take_for().
|
inlinenoexcept |
Give the semaphore.
Definition at line 125 of file sem.hpp.
References zpp::sem_base< T_Sem >::give().
|
inlinenoexcept |
Give the semaphore n times.
n | The number of times to give the semaphore |
Definition at line 145 of file sem.hpp.
References zpp::sem_base< T_Sem >::give().
|
inlinenoexcept |
Take the semaphore waiting forever.
Definition at line 133 of file sem.hpp.
References zpp::sem_base< T_Sem >::take(), and zpp::this_thread::yield().
|
inlinenoexcept |
Take the semaphore n times, waiting forever.
n | The number of times to take the semaphore |
Definition at line 157 of file sem.hpp.
References zpp::sem_base< T_Sem >::take(), and zpp::this_thread::yield().
|
delete |
|
delete |
|
inlinenoexcept |
Reset the semaphore counter to zero.
Definition at line 107 of file sem.hpp.
References zpp::sem_base< T_Sem >::native_handle().
|
inlinenoexcept |
Take the semaphore waiting forever.
Definition at line 54 of file sem.hpp.
References zpp::sem_base< T_Sem >::native_handle().
Referenced by zpp::sem_base< T_Sem >::operator--(), and zpp::sem_base< T_Sem >::operator-=().
|
inlinenoexcept |
Try to take the semaphore without waiting.
Definition at line 68 of file sem.hpp.
References zpp::sem_base< T_Sem >::native_handle().
|
inlinenoexcept |
Try to take the semaphore waiting a certain timeout.
timeout_duration | The timeout to wait before giving up |
Definition at line 86 of file sem.hpp.
References zpp::sem_base< T_Sem >::native_handle(), and zpp::to_timeout().
|
staticconstexpr |