zpp
Zephyr C++20 Framework
zpp::atomic_bitset< T_BitsetSize > Class Template Reference

class wrapping an atomic_var_t array More...

#include <atomic_bitset.hpp>

Public Member Functions

constexpr atomic_bitset () noexcept=default
 default constructor More...
 
constexpr size_t bit_count () const noexcept
 return size of the bitset More...
 
bool load (size_t bit) const noexcept
 atomically get a bit from the bitset More...
 
void store (size_t bit, bool val) noexcept
 atomically set a bit a value More...
 
void set (size_t bit) noexcept
 atomically set a bit to true/1 More...
 
void clear (size_t bit) noexcept
 atomically set a bit to false/0 More...
 
bool fetch_and_clear (size_t bit) noexcept
 atomically clear a bit while returning the previous value. More...
 
bool fetch_and_set (size_t bit) noexcept
 atomically set a bit while returning the previous value. More...
 
 atomic_bitset (const atomic_bitset &)=delete
 
 atomic_bitset (atomic_bitset &&)=delete
 
atomic_bitsetoperator= (const atomic_bitset &)=delete
 
atomic_bitsetoperator= (atomic_bitset &&)=delete
 

Detailed Description

template<size_t T_BitsetSize>
class zpp::atomic_bitset< T_BitsetSize >

class wrapping an atomic_var_t array

Parameters
BitsetSizethe size of the bitset in bits

Definition at line 23 of file atomic_bitset.hpp.

Constructor & Destructor Documentation

◆ atomic_bitset() [1/3]

template<size_t T_BitsetSize>
constexpr zpp::atomic_bitset< T_BitsetSize >::atomic_bitset ( )
constexprdefaultnoexcept

default constructor

The default constructor initializes the atomic_bitset to all bits set to 0.

◆ atomic_bitset() [2/3]

template<size_t T_BitsetSize>
zpp::atomic_bitset< T_BitsetSize >::atomic_bitset ( const atomic_bitset< T_BitsetSize > &  )
delete

◆ atomic_bitset() [3/3]

template<size_t T_BitsetSize>
zpp::atomic_bitset< T_BitsetSize >::atomic_bitset ( atomic_bitset< T_BitsetSize > &&  )
delete

Member Function Documentation

◆ bit_count()

template<size_t T_BitsetSize>
constexpr size_t zpp::atomic_bitset< T_BitsetSize >::bit_count ( ) const
inlineconstexprnoexcept

return size of the bitset

Returns
the size of the bitset in bits

Definition at line 38 of file atomic_bitset.hpp.

39  {
40  return T_BitsetSize;
41  }

◆ clear()

template<size_t T_BitsetSize>
void zpp::atomic_bitset< T_BitsetSize >::clear ( size_t  bit)
inlinenoexcept

atomically set a bit to false/0

Parameters
bitthe index of the bit to set

Definition at line 84 of file atomic_bitset.hpp.

85  {
86  __ASSERT_NO_MSG(bit < T_BitsetSize);
87  atomic_clear_bit(m_var, bit);
88  }

◆ fetch_and_clear()

template<size_t T_BitsetSize>
bool zpp::atomic_bitset< T_BitsetSize >::fetch_and_clear ( size_t  bit)
inlinenoexcept

atomically clear a bit while returning the previous value.

Parameters
bitthe index of the bit to set
Returns
the bit value before it was cleared

Definition at line 97 of file atomic_bitset.hpp.

98  {
99  __ASSERT_NO_MSG(bit < T_BitsetSize);
100  return atomic_test_and_clear_bit(m_var, bit);
101  }

◆ fetch_and_set()

template<size_t T_BitsetSize>
bool zpp::atomic_bitset< T_BitsetSize >::fetch_and_set ( size_t  bit)
inlinenoexcept

atomically set a bit while returning the previous value.

Parameters
bitthe index of the bit to set
Returns
the bit value before it was set

Definition at line 110 of file atomic_bitset.hpp.

111  {
112  __ASSERT_NO_MSG(bit < T_BitsetSize);
113  return atomic_test_and_set_bit(m_var, bit);
114  }

◆ load()

template<size_t T_BitsetSize>
bool zpp::atomic_bitset< T_BitsetSize >::load ( size_t  bit) const
inlinenoexcept

atomically get a bit from the bitset

Parameters
bitthe index of the bit to return
Returns
the requested bit value

Definition at line 50 of file atomic_bitset.hpp.

51  {
52  __ASSERT_NO_MSG(bit < T_BitsetSize);
53  return atomic_test_bit(m_var, bit);
54  }

◆ operator=() [1/2]

template<size_t T_BitsetSize>
atomic_bitset& zpp::atomic_bitset< T_BitsetSize >::operator= ( atomic_bitset< T_BitsetSize > &&  )
delete

◆ operator=() [2/2]

template<size_t T_BitsetSize>
atomic_bitset& zpp::atomic_bitset< T_BitsetSize >::operator= ( const atomic_bitset< T_BitsetSize > &  )
delete

◆ set()

template<size_t T_BitsetSize>
void zpp::atomic_bitset< T_BitsetSize >::set ( size_t  bit)
inlinenoexcept

atomically set a bit to true/1

Parameters
bitthe index of the bit to set

Definition at line 73 of file atomic_bitset.hpp.

74  {
75  __ASSERT_NO_MSG(bit < T_BitsetSize);
76  atomic_set_bit(m_var, bit);
77  }

◆ store()

template<size_t T_BitsetSize>
void zpp::atomic_bitset< T_BitsetSize >::store ( size_t  bit,
bool  val 
)
inlinenoexcept

atomically set a bit a value

Parameters
bitthe index of the bit to set
valthe value the bit should be set to

Definition at line 62 of file atomic_bitset.hpp.

63  {
64  __ASSERT_NO_MSG(bit < T_BitsetSize);
65  atomic_set_bit_to(m_var, bit, val);
66  }

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