ELEC-C7222
Libraries for ELEC C7222 Course Work
Loading...
Searching...
No Matches
c7222::FreeRtosCriticalSection Class Reference

Critical-section wrapper with destructor-based exit cleanup. More...

#include <freertos_critical_section.hpp>

Inheritance diagram for c7222::FreeRtosCriticalSection:
Inheritance graph
Collaboration diagram for c7222::FreeRtosCriticalSection:
Collaboration graph

Public Member Functions

 FreeRtosCriticalSection ()=default
 Construct a critical-section wrapper in the unlocked state.
 
 ~FreeRtosCriticalSection ()
 Ensure the critical section is exited on destruction if entered.
 
void Enter ()
 Enter the critical section (no-op if already entered by this object).
 
bool Exit ()
 Exit the critical section.
 
bool IsEntered () const
 
- Public Member Functions inherited from c7222::NonCopyable
 NonCopyable (const NonCopyable &)=delete
 
NonCopyableoperator= (const NonCopyable &)=delete
 
 NonCopyable (NonCopyable &&)=default
 
NonCopyableoperator= (NonCopyable &&)=default
 
- Public Member Functions inherited from c7222::NonMovable
 NonMovable (const NonMovable &)=default
 
NonMovableoperator= (const NonMovable &)=default
 
 NonMovable (NonMovable &&)=delete
 
NonMovableoperator= (NonMovable &&)=delete
 

Additional Inherited Members

- Protected Member Functions inherited from c7222::NonCopyableNonMovable
 NonCopyableNonMovable ()=default
 
 ~NonCopyableNonMovable ()=default
 
- Protected Member Functions inherited from c7222::NonCopyable
 NonCopyable ()=default
 
 ~NonCopyable ()=default
 
- Protected Member Functions inherited from c7222::NonMovable
 NonMovable ()=default
 
 ~NonMovable ()=default
 

Detailed Description

Critical-section wrapper with destructor-based exit cleanup.

This wrapper protects short non-blocking regions that must not be interrupted by context switches/interrupt handlers (platform dependent).

The object tracks a binary entered state (depth_ is 0 or 1). Calling Enter() while already entered is a no-op for this object, and destruction exits the critical section if it is still entered.

Typical usage:

cs.Enter();
// very short non-blocking critical region
(void)cs.Exit();
Critical-section wrapper with destructor-based exit cleanup.
Definition freertos_critical_section.hpp:34
bool Exit()
Exit the critical section.
void Enter()
Enter the critical section (no-op if already entered by this object).

Constructor & Destructor Documentation

◆ FreeRtosCriticalSection()

c7222::FreeRtosCriticalSection::FreeRtosCriticalSection ( )
default

Construct a critical-section wrapper in the unlocked state.

◆ ~FreeRtosCriticalSection()

c7222::FreeRtosCriticalSection::~FreeRtosCriticalSection ( )

Ensure the critical section is exited on destruction if entered.

Member Function Documentation

◆ Enter()

void c7222::FreeRtosCriticalSection::Enter ( )

Enter the critical section (no-op if already entered by this object).

◆ Exit()

bool c7222::FreeRtosCriticalSection::Exit ( )

Exit the critical section.

Returns
false if not currently entered.

◆ IsEntered()

bool c7222::FreeRtosCriticalSection::IsEntered ( ) const
Returns
true if this object is currently entered.

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