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

Ownership-based wrapper for a standard mutex with destructor cleanup. More...

#include <freertos_mutex.hpp>

Inheritance diagram for c7222::FreeRtosMutex:
Inheritance graph
Collaboration diagram for c7222::FreeRtosMutex:
Collaboration graph

Public Member Functions

 FreeRtosMutex ()
 Construct and initialize a mutex.
 
bool Initialize ()
 Initialize (or re-initialize) the mutex.
 
 ~FreeRtosMutex ()
 Destroy mutex resources if initialized.
 
bool Lock (std::uint32_t ticks_to_wait=0)
 Acquire the mutex.
 
bool TryLock ()
 Non-blocking lock attempt.
 
bool Unlock ()
 Release the mutex.
 
bool IsValid () 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

Ownership-based wrapper for a standard mutex with destructor cleanup.

This mutex is intended for mutual exclusion in task context. Lock/unlock is explicit (Lock() / Unlock()), not constructor/destructor scoped locking.

Typical usage:

if(mutex.Lock(10)) {
// access shared state
(void)mutex.Unlock();
}
Ownership-based wrapper for a standard mutex with destructor cleanup.
Definition freertos_mutex.hpp:31
bool Lock(std::uint32_t ticks_to_wait=0)
Acquire the mutex.
bool Unlock()
Release the mutex.

Constructor & Destructor Documentation

◆ FreeRtosMutex()

c7222::FreeRtosMutex::FreeRtosMutex ( )

Construct and initialize a mutex.

◆ ~FreeRtosMutex()

c7222::FreeRtosMutex::~FreeRtosMutex ( )

Destroy mutex resources if initialized.

Member Function Documentation

◆ Initialize()

bool c7222::FreeRtosMutex::Initialize ( )

Initialize (or re-initialize) the mutex.

◆ IsValid()

bool c7222::FreeRtosMutex::IsValid ( ) const
Returns
true if the wrapper owns a valid mutex handle.

◆ Lock()

bool c7222::FreeRtosMutex::Lock ( std::uint32_t  ticks_to_wait = 0)

Acquire the mutex.

Parameters
ticks_to_waitMax ticks to wait (0 = non-blocking).
Returns
true if acquired.

◆ TryLock()

bool c7222::FreeRtosMutex::TryLock ( )

Non-blocking lock attempt.

◆ Unlock()

bool c7222::FreeRtosMutex::Unlock ( )

Release the mutex.


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