SensESP 3.0.1
Universal Signal K sensor toolkit ESP32
|
A value container wrapped in a semaphore. More...
#include <sensesp/system/semaphore_value.h>
Public Member Functions | |
SemaphoreValue () | |
bool | wait (T &destination, unsigned int max_duration_ms) |
Wait for the value to be updated. | |
bool | take (unsigned int max_duration_ms) |
Take the semaphore, ignoring the value. | |
void | set (const T &new_value) override |
void | clear () |
Public Member Functions inherited from sensesp::ValueConsumer< T > | |
virtual void | set_input (const T &new_value) |
void | connect_from (ValueProducer< T > *producer) |
Protected Attributes | |
T | value_ |
SemaphoreHandle_t | semaphore_ |
Additional Inherited Members | |
Public Types inherited from sensesp::ValueConsumer< T > | |
using | input_type = T |
A value container wrapped in a semaphore.
SemaphoreValue is primarily useful for synchronizing access to a value. It is a regular ValueConsumer that can receive values from a ValueProducer. The value is wrapped in a semaphore which can be waited on. This allows a thread to wait until the value is updated, making SemaphoreValue useful for synchronizing threads.
SemaphoreValue is similar to TaskQueueProducer, but it is not a queue and does not poll or emit the values.
Definition at line 24 of file semaphore_value.h.
|
inline |
Definition at line 26 of file semaphore_value.h.
|
inline |
Definition at line 59 of file semaphore_value.h.
|
inlineoverridevirtual |
Used to set an input of this consumer. It is called automatically by a ValueProducer but can also be called manually.
new_value | the value of the input |
Reimplemented from sensesp::ValueConsumer< T >.
Definition at line 54 of file semaphore_value.h.
|
inline |
Take the semaphore, ignoring the value.
Definition at line 49 of file semaphore_value.h.
|
inline |
Wait for the value to be updated.
This method blocks until the value is updated.
Definition at line 36 of file semaphore_value.h.
|
protected |
Definition at line 63 of file semaphore_value.h.
|
protected |
Definition at line 62 of file semaphore_value.h.