|
SensESP 3.3.0
Universal Signal K sensor toolkit ESP32
|
Producer class that works across task boundaries. More...
#include <sensesp/system/task_queue_producer.h>
Public Member Functions | |
| TaskQueueProducer (const T &value, std::shared_ptr< reactesp::EventLoop > consumer_event_loop, unsigned int poll_rate=990) | |
| TaskQueueProducer (const T &value, unsigned int poll_rate=990) | |
| virtual void | set (const T &value) override |
| bool | wait (T &value, unsigned int max_duration_ms) |
| Wait for a value to be available in the queue. | |
| Public Member Functions inherited from sensesp::ObservableValue< T > | |
| ObservableValue ()=default | |
| ObservableValue (const T &value) | |
| ObservableValue (const ObservableValue &)=delete | |
| ObservableValue & | operator= (const ObservableValue &)=delete |
| const T & | operator= (const T &value) |
| T & | operator++ () |
| T & | operator-- () |
| T | operator++ (int) |
| T | operator-- (int) |
| const T & | operator+= (const T &value) |
| const T & | operator-= (const T &value) |
| Public Member Functions inherited from sensesp::ValueConsumer< T > | |
| virtual void | set_input (const T &new_value) |
| void | connect_from (ValueProducer< T > *producer) |
| Public Member Functions inherited from sensesp::ValueProducer< T > | |
| ValueProducer () | |
| ValueProducer (const T &initial_value) | |
| virtual const T & | get () const |
| template<typename VConsumer> | |
| std::enable_if< std::is_base_of< ValueConsumer< typenameVConsumer::input_type >, VConsumer >::value &&std::is_convertible< T, typenameVConsumer::input_type >::value, std::shared_ptr< VConsumer > >::type | connect_to (std::shared_ptr< VConsumer > consumer) |
| Connect a producer to a transform with a different input type. | |
| template<typename VConsumer> | |
| std::enable_if< std::is_base_of< ValueConsumer< typenameVConsumer::input_type >, VConsumer >::value &&std::is_convertible< T, typenameVConsumer::input_type >::value, VConsumer * >::type | connect_to (VConsumer *consumer) |
| template<typename VConsumer> | |
| std::enable_if< std::is_base_of< ValueConsumer< typenameVConsumer::input_type >, VConsumer >::value &&std::is_convertible< T, typenameVConsumer::input_type >::value, VConsumer * >::type | connect_to (VConsumer &consumer) |
| void | emit (const T &new_value) |
| Public Member Functions inherited from sensesp::Observable | |
| Observable () | |
| Observable (Observable &&other) | |
| Move constructor. | |
| void | notify () |
| int | attach (std::function< void()> observer) |
| Attach an observer callback. | |
| void | detach (int id) |
| Remove a previously attached observer by its ID. | |
Additional Inherited Members | |
| Public Types inherited from sensesp::ValueConsumer< T > | |
| using | input_type = T |
| Protected Attributes inherited from sensesp::ValueProducer< T > | |
| T | output_ |
Producer class that works across task boundaries.
Normal ObservableValues call the observer callbacks within the same task content. In a multi-task software, this is not always preferable. This class allows you to produce values in one task and consume them in another.
| T |
| consumer_event_loop | The event loop in which the values should be consumed. |
| poll_rate | How often to poll the queue. Note: in microseconds! A value of 0 means that the queue will be polled on every tick. |
Definition at line 105 of file task_queue_producer.h.
|
inline |
Definition at line 107 of file task_queue_producer.h.
|
inline |
|
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::ObservableValue< T >.
Definition at line 129 of file task_queue_producer.h.
|
inline |
Wait for a value to be available in the queue.
This function will block until a value is available in the queue. When a value becomes available, it will be returned in the reference and emitted to the observers.
WARNING: wait() calls emit(), which invokes all observers. This is only safe if wait() is called from the same FreeRTOS task where observers were registered (typically the main event loop task). For cross-task use, rely on the polling lambda set up in the constructor.
| value | Received value if the function returns true. |
| max_duration_ms | Maximum duration to wait for the value. |
Definition at line 148 of file task_queue_producer.h.