RTOS Wrapper
API reference
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | Static Private Attributes | List of all members
SignalSemaphore Class Reference

SignalSemaphore class for managing a named semaphore. More...

#include <SignalSemaphore.h>

Public Member Functions

 SignalSemaphore (const char *baseName, const char *nameExtension=nullptr) noexcept
 Constructor for SignalSemaphore.
 
 SignalSemaphore (const SignalSemaphore &copy)=delete
 Deleted copy constructor to avoid copying instances.
 
SignalSemaphore & operator= (const SignalSemaphore &copy)=delete
 Deleted assignment operator to avoid copying instances.
 
 ~SignalSemaphore ()
 Destructor for SignalSemaphore.
 
bool WaitUntilSignalled (uint32_t msecToWait=OS_WAIT_FOREVER) noexcept
 Waits until the semaphore is signaled.
 
bool Signal () noexcept
 Signals the semaphore.
 
bool IsSignalled () noexcept
 Checks if the semaphore is signaled.
 
bool EnsureInitialized () noexcept
 Ensures the semaphore is initialized.
 
bool IsInitialized () const noexcept
 Checks if the semaphore is initialized.
 
const char * GetName () const noexcept
 Gets the name of the semaphore.
 

Private Attributes

OS_Semaphore semaphore
 The semaphore object.
 
char name [MaxNameLength+1]
 The name of the semaphore.
 
bool initialized
 Indicates whether the semaphore is initialized.
 

Static Private Attributes

static constexpr uint32_t MaxNameLength = 39U
 Maximum length of the semaphore name (excluding null terminator).
 

Detailed Description

SignalSemaphore class for managing a named semaphore.

Constructor & Destructor Documentation

◆ SignalSemaphore() [1/2]

SignalSemaphore::SignalSemaphore ( const char *  baseName,
const char *  nameExtension = nullptr 
)
noexcept

Constructor for SignalSemaphore.

Parameters
baseNameBase name of the semaphore.
nameExtensionOptional name extension for uniqueness.
Todo:
Add
Example
int main() {
SignalSemaphore semaphore("MySemaphore");
// Signal the semaphore
semaphore.Signal();
// Wait until the semaphore is signaled
if (semaphore.WaitUntilSignalled(1000)) {
// Semaphore was signaled
} else {
// Timeout occurred
}
return 0;
}
SignalSemaphore class definition.
SignalSemaphore class for managing a named semaphore.
Definition SignalSemaphore.h:21
OS_Semaphore semaphore
The semaphore object.
Definition SignalSemaphore.h:86
Parameters
baseNameBase name of the semaphore.
nameExtensionOptional name extension for uniqueness.

◆ SignalSemaphore() [2/2]

SignalSemaphore::SignalSemaphore ( const SignalSemaphore &  copy)
delete

Deleted copy constructor to avoid copying instances.

◆ ~SignalSemaphore()

SignalSemaphore::~SignalSemaphore ( )

Destructor for SignalSemaphore.

Member Function Documentation

◆ EnsureInitialized()

bool SignalSemaphore::EnsureInitialized ( )
noexcept

Ensures the semaphore is initialized.

Returns
True if the semaphore is initialized, false otherwise.

◆ GetName()

const char * SignalSemaphore::GetName ( ) const
noexcept

Gets the name of the semaphore.

Returns
The name of the semaphore.

◆ IsInitialized()

bool SignalSemaphore::IsInitialized ( ) const
noexcept

Checks if the semaphore is initialized.

Returns
True if the semaphore is initialized, false otherwise.

◆ IsSignalled()

bool SignalSemaphore::IsSignalled ( )
noexcept

Checks if the semaphore is signaled.

Returns
True if the semaphore is signaled, false otherwise.

◆ operator=()

SignalSemaphore & SignalSemaphore::operator= ( const SignalSemaphore &  copy)
delete

Deleted assignment operator to avoid copying instances.

◆ Signal()

bool SignalSemaphore::Signal ( )
noexcept

Signals the semaphore.

Returns
True if the semaphore was successfully signaled, false otherwise.

◆ WaitUntilSignalled()

bool SignalSemaphore::WaitUntilSignalled ( uint32_t  msecToWait = OS_WAIT_FOREVER)
noexcept

Waits until the semaphore is signaled.

Parameters
msecToWaitMaximum time to wait in milliseconds.
Returns
True if the semaphore was successfully acquired, false otherwise.

Member Data Documentation

◆ initialized

bool SignalSemaphore::initialized
private

Indicates whether the semaphore is initialized.

◆ MaxNameLength

constexpr uint32_t SignalSemaphore::MaxNameLength = 39U
staticconstexprprivate

Maximum length of the semaphore name (excluding null terminator).

◆ name

char SignalSemaphore::name[MaxNameLength+1]
private

The name of the semaphore.

◆ semaphore

OS_Semaphore SignalSemaphore::semaphore
private

The semaphore object.


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