DelegateMQ
Loading...
Searching...
No Matches
dmq::FreeRTOSConditionVariable Class Reference

Production-grade wrapper around FreeRTOS Semaphore to mimic std::condition_variable. More...

#include <FreeRTOSConditionVariable.h>

Public Member Functions

 FreeRTOSConditionVariable ()
 
 ~FreeRTOSConditionVariable ()
 
 FreeRTOSConditionVariable (const FreeRTOSConditionVariable &)=delete
 
FreeRTOSConditionVariableoperator= (const FreeRTOSConditionVariable &)=delete
 
void notify_one () noexcept
 Wake up one waiting thread (ISR Safe)
 
template<typename Lock , typename Predicate >
void wait (Lock &lock, Predicate pred)
 Wait indefinitely until predicate is true.
 
template<typename Lock , typename Predicate >
bool wait_for (Lock &lock, std::chrono::milliseconds timeout, Predicate pred)
 Wait until predicate is true or timeout expires.
 

Detailed Description

Production-grade wrapper around FreeRTOS Semaphore to mimic std::condition_variable.

  • Uses a Binary Semaphore (1 token).
  • ISR-safe notification logic.
  • Robust tick overflow handling using elapsed time subtraction.
Note
Limitation: Unlike std::cv, a binary semaphore retains its signal state. If notify() occurs before wait(), the wait will effectively "fall through". Multiple notifies before a wait are coalesced into a single signal.

Constructor & Destructor Documentation

◆ FreeRTOSConditionVariable() [1/2]

dmq::FreeRTOSConditionVariable::FreeRTOSConditionVariable ( )
inline

◆ ~FreeRTOSConditionVariable()

dmq::FreeRTOSConditionVariable::~FreeRTOSConditionVariable ( )
inline

◆ FreeRTOSConditionVariable() [2/2]

dmq::FreeRTOSConditionVariable::FreeRTOSConditionVariable ( const FreeRTOSConditionVariable & )
delete

Member Function Documentation

◆ notify_one()

void dmq::FreeRTOSConditionVariable::notify_one ( )
inlinenoexcept

Wake up one waiting thread (ISR Safe)

◆ operator=()

FreeRTOSConditionVariable & dmq::FreeRTOSConditionVariable::operator= ( const FreeRTOSConditionVariable & )
delete

◆ wait()

template<typename Lock , typename Predicate >
void dmq::FreeRTOSConditionVariable::wait ( Lock & lock,
Predicate pred )
inline

Wait indefinitely until predicate is true.

◆ wait_for()

template<typename Lock , typename Predicate >
bool dmq::FreeRTOSConditionVariable::wait_for ( Lock & lock,
std::chrono::milliseconds timeout,
Predicate pred )
inline

Wait until predicate is true or timeout expires.

Uses overflow-safe subtraction logic to track elapsed ticks.


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