1 #ifndef ESP8266NDN_PORT_QUEUE_FREERTOS_HPP
2 #define ESP8266NDN_PORT_QUEUE_FREERTOS_HPP
9 #if defined(ARDUINO_ARCH_RP2040)
14 #include <freertos/FreeRTOS.h>
15 #include <freertos/queue.h>
19 namespace ndnph_port_freertos {
22 template<
typename T,
size_t capacity>
26 static_assert(std::is_trivially_copyable<Item>::value,
"");
27 static_assert(std::is_trivially_destructible<Item>::value,
"");
30 m_queue = xQueueCreate(capacity,
sizeof(
Item));
34 vQueueDelete(m_queue);
38 BaseType_t res = xQueueSendToBack(m_queue, &item, 0);
42 std::tuple<Item, bool>
pop() {
44 BaseType_t res = xQueueReceive(m_queue, &item, 0);
45 return std::make_tuple(std::move(item), res == pdTRUE);
49 QueueHandle_t m_queue;
55 #ifdef ESP8266NDN_PORT_QUEUE_FREERTOS
58 template<
typename T,
size_t capacity>
Generic thread-safe queue, implemented with FreeRTOS queue API.
Definition: queue-freertos.hpp:23
~SafeQueue()
Definition: queue-freertos.hpp:33
T Item
Definition: queue-freertos.hpp:25
SafeQueue()
Definition: queue-freertos.hpp:29
bool push(Item item)
Definition: queue-freertos.hpp:37
std::tuple< Item, bool > pop()
Definition: queue-freertos.hpp:42
Definition: autoconfig.hpp:24