12#ifndef CMSIS_PLUS_RTOS_OS_SEMAPHORE_H_
13#define CMSIS_PLUS_RTOS_OS_SEMAPHORE_H_
17#if defined(__cplusplus)
21#if defined(OS_USE_OS_APP_CONFIG_H)
22#include <cmsis-plus/os-app-config.h>
29#pragma GCC diagnostic push
31#pragma clang diagnostic ignored "-Wc++98-compat"
32#pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
43#pragma GCC diagnostic push
45#pragma clang diagnostic ignored "-Wpadded"
46#elif defined(__GNUC__)
47#pragma GCC diagnostic ignored "-Wpadded"
456 internal_init_ (
void);
459 internal_try_wait_ (
void);
479#if !defined(OS_USE_RTOS_PORT_SEMAPHORE)
481 clock* clock_ =
nullptr;
484#if defined(OS_USE_RTOS_PORT_SEMAPHORE)
485 friend class port::semaphore;
486 os_semaphore_port_data_t port_;
492 const count_t initial_value_ = 0;
658#pragma GCC diagnostic pop
764 return initial_value_;
803 :
semaphore{ nullptr, 1, initial_value, initializer_binary }
884 :
semaphore{ nullptr, max_value, initial_value }
912 :
semaphore{ name, max_value, initial_value }
946#pragma GCC diagnostic pop
Base class for attributes.
Base class for named system objects.
const char * name(void) const
Get object name.
Priority ordered list of threads.
Binary semaphore attributes.
constexpr attributes_binary(count_t initial_value)
Construct a binary semaphore attributes object instance.
~attributes_binary()=default
Destruct the semaphore attributes object instance.
attributes_binary & operator=(const attributes_binary &)=default
attributes_binary(attributes_binary &&)=default
attributes_binary(const attributes_binary &)=default
Counting semaphore attributes.
attributes_counting & operator=(const attributes_counting &)=default
constexpr attributes_counting(count_t max_value, count_t initial_value)
Construct a counting semaphore attributes object instance.
attributes_counting(attributes_counting &&)=default
attributes_counting(const attributes_counting &)=default
~attributes_counting()=default
Destruct the semaphore attributes object instance.
count_t sm_max_value
Semaphore max count value.
~attributes()=default
Destruct the semaphore attributes object instance.
attributes(const attributes &)=default
constexpr attributes()
Construct a semaphore attributes object instance.
count_t sm_initial_value
Semaphore initial count value.
attributes & operator=(const attributes &)=default
attributes(attributes &&)=default
POSIX compliant binary semaphore.
~semaphore_binary()
Destruct the semaphore object instance.
bool operator==(const semaphore_binary &rhs) const
Compare semaphores.
semaphore_binary(const count_t initial_value)
Construct a binary semaphore object instance.
POSIX compliant counting semaphore.
~semaphore_counting()
Destruct the semaphore object instance.
bool operator==(const semaphore_counting &rhs) const
Compare semaphores.
semaphore_counting(const count_t max_value, const count_t initial_value)
Construct a binary semaphore object instance.
POSIX compliant semaphore.
result_t timed_wait(clock::duration_t timeout)
Timed wait to lock the semaphore.
result_t wait(void)
Lock the semaphore, possibly waiting.
result_t reset(void)
Reset the semaphore.
result_t post(void)
Post (unlock) the semaphore.
result_t try_wait(void)
Try to lock the semaphore.
~semaphore()
Destruct the semaphore object instance.
semaphore(const attributes &attr=initializer_binary)
Construct a semaphore object instance.
count_t max_value(void) const
Get the semaphore maximum count value.
count_t initial_value(void) const
Get the semaphore initial count value.
count_t value(void) const
Get the semaphore count value.
bool operator==(const semaphore &rhs) const
Compare semaphores.
port::clock::duration_t duration_t
Type of variables holding clock durations.
static constexpr count_t max_count_value
Maximum semaphore value.
static const attributes_binary initializer_binary
Default binary semaphore initialiser.
int16_t count_t
Type of semaphore counter storage.
uint32_t result_t
Type of values returned by RTOS functions.