RTOS Wrapper
API reference
Loading...
Searching...
No Matches
SignalSemaphore.h
Go to the documentation of this file.
1
10#ifndef SIGNALSEMAPHORE_H
11#define SIGNALSEMAPHORE_H
12
13#include <stdint.h>
14#include "OsUtility.h"
15#include <cstdio>
16
21{
22public:
28 SignalSemaphore(const char* baseName, const char* nameExtension = nullptr) noexcept;
29
33 SignalSemaphore(const SignalSemaphore& copy) = delete;
34
39
44
50 bool WaitUntilSignalled(uint32_t msecToWait = OS_WAIT_FOREVER) noexcept;
51
56 bool Signal() noexcept;
57
62 bool IsSignalled() noexcept;
63
68 bool EnsureInitialized() noexcept;
69
74 bool IsInitialized() const noexcept;
75
80 const char* GetName() const noexcept;
81
82private:
83
84 static constexpr uint32_t MaxNameLength = 39U;
85
87 char name[MaxNameLength + 1];
89};
90
91#endif /* SIGNALSEMAPHORE_H */
C-facing helper functions for delays, cycle counters, and creation of RTOS handles (queues,...
SignalSemaphore class for managing a named semaphore.
Definition SignalSemaphore.h:21
bool Signal() noexcept
Signals the semaphore.
Definition SignalSemaphore.cpp:82
bool IsInitialized() const noexcept
Checks if the semaphore is initialized.
Definition SignalSemaphore.cpp:110
char name[MaxNameLength+1]
The name of the semaphore.
Definition SignalSemaphore.h:87
~SignalSemaphore()
Destructor for SignalSemaphore.
Definition SignalSemaphore.cpp:56
const char * GetName() const noexcept
Gets the name of the semaphore.
Definition SignalSemaphore.cpp:119
SignalSemaphore(const SignalSemaphore &copy)=delete
Deleted copy constructor to avoid copying instances.
bool WaitUntilSignalled(uint32_t msecToWait=OS_WAIT_FOREVER) noexcept
Waits until the semaphore is signaled.
Definition SignalSemaphore.cpp:69
bool IsSignalled() noexcept
Checks if the semaphore is signaled.
Definition SignalSemaphore.cpp:96
static constexpr uint32_t MaxNameLength
Maximum length of the semaphore name (excluding null terminator).
Definition SignalSemaphore.h:84
OS_Semaphore semaphore
The semaphore object.
Definition SignalSemaphore.h:86
bool initialized
Indicates whether the semaphore is initialized.
Definition SignalSemaphore.h:88
SignalSemaphore & operator=(const SignalSemaphore &copy)=delete
Deleted assignment operator to avoid copying instances.
bool EnsureInitialized() noexcept
Ensures the semaphore is initialized.
Definition SignalSemaphore.cpp:128
@ OS_WAIT_FOREVER
Definition os_cmsis.h:48
osSemaphoreId_t OS_Semaphore
Definition os_cmsis.h:29