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. | |
![]() | |
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) |
![]() | |
virtual void | set_input (const T &new_value) |
void | connect_from (ValueProducer< T > *producer) |
![]() | |
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) |
![]() | |
Observable () | |
Observable (Observable &&other) | |
Move constructor. | |
void | notify () |
void | attach (std::function< void()> observer) |
Additional Inherited Members | |
![]() | |
using | input_type = 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 80 of file task_queue_producer.h.
|
inline |
|
inline |
Definition at line 101 of file task_queue_producer.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::ObservableValue< T >.
Definition at line 104 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.
value | Received value if the function returns true. |
max_duration_ms | Maximum duration to wait for the value. |
Definition at line 118 of file task_queue_producer.h.