RTOS Wrapper
API reference
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
hf::SeqlockSnapshot< T > Class Template Referencefinal

#include <SeqlockSnapshot.h>

Inheritance diagram for hf::SeqlockSnapshot< T >:
hf::SnapshotReader< T > hf::SnapshotWriter< T >

Public Member Functions

 SeqlockSnapshot () noexcept=default
 
 ~SeqlockSnapshot () override
 
 SeqlockSnapshot (const SeqlockSnapshot &)=delete
 
SeqlockSnapshot & operator= (const SeqlockSnapshot &)=delete
 
void Publish (const T &value) noexcept override
 Atomically replace the published snapshot with value.
 
uint32_t Read (T &out) const noexcept override
 Read the latest coherent snapshot.
 
uint32_t Seq () const noexcept override
 Monotonic change counter (each successful Publish adds 2).
 
bool WaitForChange (uint32_t timeout_ms) noexcept override
 Block up to timeout_ms waiting for any change since the last call to WaitForChange / ClearWaitEvent.
 
bool ClearWaitEvent () noexcept override
 Drop any pending change-signal without waiting.
 
- Public Member Functions inherited from hf::SnapshotReader< T >
virtual ~SnapshotReader () noexcept=default
 
- Public Member Functions inherited from hf::SnapshotWriter< T >
virtual ~SnapshotWriter () noexcept=default
 

Private Member Functions

void SignalChange_ () noexcept
 
bool EnsureEventGroup_ () noexcept
 

Private Attributes

std::atomic< uint32_t > seq_ {0}
 
T payload_ {}
 
OS_EventGroup event_group_ {}
 
bool event_group_created_ {false}
 

Static Private Attributes

static constexpr OS_Ulong kEventBit_ = 0x1U
 

Constructor & Destructor Documentation

◆ SeqlockSnapshot() [1/2]

template<typename T >
hf::SeqlockSnapshot< T >::SeqlockSnapshot ( )
defaultnoexcept

◆ ~SeqlockSnapshot()

template<typename T >
hf::SeqlockSnapshot< T >::~SeqlockSnapshot ( )
inlineoverride

◆ SeqlockSnapshot() [2/2]

template<typename T >
hf::SeqlockSnapshot< T >::SeqlockSnapshot ( const SeqlockSnapshot< T > &  )
delete

Member Function Documentation

◆ ClearWaitEvent()

template<typename T >
bool hf::SeqlockSnapshot< T >::ClearWaitEvent ( )
inlineoverridevirtualnoexcept

Drop any pending change-signal without waiting.

Implements hf::SnapshotReader< T >.

◆ EnsureEventGroup_()

template<typename T >
bool hf::SeqlockSnapshot< T >::EnsureEventGroup_ ( )
inlineprivatenoexcept

◆ operator=()

template<typename T >
SeqlockSnapshot & hf::SeqlockSnapshot< T >::operator= ( const SeqlockSnapshot< T > &  )
delete

◆ Publish()

template<typename T >
void hf::SeqlockSnapshot< T >::Publish ( const T &  value)
inlineoverridevirtualnoexcept

Atomically replace the published snapshot with value.

Single-writer only. Increments Seq() by 2 and signals waiters.

Implements hf::SnapshotWriter< T >.

◆ Read()

template<typename T >
uint32_t hf::SeqlockSnapshot< T >::Read ( T &  out) const
inlineoverridevirtualnoexcept

Read the latest coherent snapshot.

Returns
current sequence (post-read); always even on success.

Implements hf::SnapshotReader< T >.

◆ Seq()

template<typename T >
uint32_t hf::SeqlockSnapshot< T >::Seq ( ) const
inlineoverridevirtualnoexcept

Monotonic change counter (each successful Publish adds 2).

Implements hf::SnapshotReader< T >.

◆ SignalChange_()

template<typename T >
void hf::SeqlockSnapshot< T >::SignalChange_ ( )
inlineprivatenoexcept

◆ WaitForChange()

template<typename T >
bool hf::SeqlockSnapshot< T >::WaitForChange ( uint32_t  timeout_ms)
inlineoverridevirtualnoexcept

Block up to timeout_ms waiting for any change since the last call to WaitForChange / ClearWaitEvent.

Implements hf::SnapshotReader< T >.

Member Data Documentation

◆ event_group_

template<typename T >
OS_EventGroup hf::SeqlockSnapshot< T >::event_group_ {}
private

◆ event_group_created_

template<typename T >
bool hf::SeqlockSnapshot< T >::event_group_created_ {false}
private

◆ kEventBit_

template<typename T >
constexpr OS_Ulong hf::SeqlockSnapshot< T >::kEventBit_ = 0x1U
staticconstexprprivate

◆ payload_

template<typename T >
T hf::SeqlockSnapshot< T >::payload_ {}
private

◆ seq_

template<typename T >
std::atomic<uint32_t> hf::SeqlockSnapshot< T >::seq_ {0}
mutableprivate

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