Mbed OS Reference
|
The Semaphore class is used to manage and protect access to a set of shared resources. More...
#include <Semaphore.h>
Public Member Functions | |
Semaphore (int32_t count=0) | |
Create and Initialize a Semaphore object used for managing resources. More... | |
Semaphore (int32_t count, uint16_t max_count) | |
Create and Initialize a Semaphore object used for managing resources. More... | |
void | acquire () |
Wait until a Semaphore resource becomes available. More... | |
bool | try_acquire () |
Try to acquire a Semaphore resource, and return immediately. More... | |
bool | try_acquire_for (uint32_t millisec) |
Wait until a Semaphore resource becomes available. More... | |
bool | try_acquire_for (Kernel::Clock::duration_u32 rel_time) |
Wait until a Semaphore resource becomes available. More... | |
bool | try_acquire_until (uint64_t millisec) |
Wait until a Semaphore resource becomes available. More... | |
bool | try_acquire_until (Kernel::Clock::time_point abs_time) |
Wait until a Semaphore resource becomes available. More... | |
osStatus | release (void) |
Release a Semaphore resource that was obtain with Semaphore::acquire. More... | |
~Semaphore () | |
Semaphore destructor. More... | |
The Semaphore class is used to manage and protect access to a set of shared resources.
Definition at line 50 of file Semaphore.h.
Semaphore | ( | int32_t | count = 0 | ) |
Create and Initialize a Semaphore object used for managing resources.
count | number of available resources; maximum index value is (count-1). (default: 0). |
Semaphore | ( | int32_t | count, |
uint16_t | max_count | ||
) |
Create and Initialize a Semaphore object used for managing resources.
count | number of available resources |
max_count | maximum number of available resources |
void acquire | ( | ) |
Wait until a Semaphore resource becomes available.
bool try_acquire | ( | ) |
Try to acquire a Semaphore resource, and return immediately.
bool try_acquire_for | ( | uint32_t | millisec | ) |
Wait until a Semaphore resource becomes available.
millisec | timeout value. |
5s
rather than 5000
. bool try_acquire_for | ( | Kernel::Clock::duration_u32 | rel_time | ) |
Wait until a Semaphore resource becomes available.
rel_time | timeout value. |
bool try_acquire_until | ( | uint64_t | millisec | ) |
Wait until a Semaphore resource becomes available.
millisec | absolute timeout time, referenced to Kernel::get_ms_count() |
Kernel::Clock::now() + 5s
rather than Kernel::get_ms_count() + 5000
. bool try_acquire_until | ( | Kernel::Clock::time_point | abs_time | ) |
Wait until a Semaphore resource becomes available.
abs_time | absolute timeout time, referenced to Kernel::Clock |
osStatus release | ( | void | ) |
Release a Semaphore resource that was obtain with Semaphore::acquire.