sourceToQueue Helper¶
-
template<typename Source>
Effect<1> RxESP32::Helpers::Utility::sourceToQueue(Source &source, QueueHandle_t &queue, TickType_t timeout_ms = 0, const Effect<1>::Options options = {})¶ Create an Effect that writes source values to a FreeRTOS queue.
Creates an Effect that listens to a source and writes its values to the specified FreeRTOS queue whenever the source updates. Non-blocking write.
- Since
v0.1.0
Signal<int> sensor(0); QueueHandle_t data_queue = xQueueCreate(10, sizeof(int)); auto effect = sourceToQueue(sensor, data_queue); // Now sensor updates are sent to data_queueWarning
Ensure the queue has the same type as the source.
Ensure the queue is large enough to avoid data loss.
Try to avoid long timeout times to prevent blocking the dispatcher (use 0 whenever possible).
See Also¶
Utility Helpers - Overview