EtcPal
0.4.1
ETC Platform Abstraction Layer (EtcPal)
|
View other versions:
|
A wrapper class for the EtcPal counting semaphore type.
Usage example:
See sem (Counting Semaphores) for more information.
Public Member Functions | |
Semaphore (unsigned int initial_count=0, unsigned int max_count=kDefaultMaxCount) | |
Create a new semaphore. | |
~Semaphore () | |
Destroy the semaphore. | |
Semaphore (const Semaphore &other)=delete | |
Semaphore & | operator= (const Semaphore &other)=delete |
Semaphore (Semaphore &&other)=delete | |
Semaphore & | operator= (Semaphore &&other)=delete |
bool | Wait () |
Wait for the semaphore. More... | |
bool | TryWait (int timeout_ms=0) |
Wait for the semaphore until either it is received or a timeout expires. More... | |
bool | Post () |
Post the semaphore. More... | |
bool | PostFromIsr () |
Post the semaphore from an interrupt context. More... | |
etcpal_sem_t & | get () |
Get a reference to the underlying etcpal_sem_t type. | |
Static Public Attributes | |
static constexpr unsigned int | kDefaultMaxCount = 50 |
The default value used for the semaphore's max_count. More... | |
|
inline |
Post the semaphore.
See etcpal_sem_post().
|
inline |
Post the semaphore from an interrupt context.
NOTE: Only meaningful on some platforms. See the table in sem (Counting Semaphores) and etcpal_sem_post_from_isr() for more information. On platforms on which it is not meaningful, executes the equivalent of Post().
|
inline |
Wait for the semaphore until either it is received or a timeout expires.
NOTE: Timeouts other than 0 or ETCPAL_WAIT_FOREVER are typically only honored on real-time platforms. See the table in sem (Counting Semaphores) for more information. On platforms where timeouts are not honored, passing 0 for timeout_ms returns immediately whether the semaphore was available and taken, while any other value executes the equivalent of Wait().
timeout_ms | How long to wait for the semaphore, in milliseconds. |
|
inline |
Wait for the semaphore.
|
staticconstexpr |
The default value used for the semaphore's max_count.
This is not honored on all platforms - see sem (Counting Semaphores) for more information.