|
idfxx 1.0.0
Modern C++23 components for ESP-IDF
|
Type-safe inter-task message queue. More...
Classes | |
| struct | isr_receive_result |
| Result of an ISR receive operation. More... | |
| struct | isr_send_result |
| Result of an ISR send operation. More... | |
Public Member Functions | |
| queue (size_t length, flags< memory_caps > mem_caps=memory_caps::dram) | |
| Creates a queue with the specified capacity. | |
| ~queue () | |
| Destroys the queue and releases all resources. | |
| queue (const queue &)=delete | |
| queue & | operator= (const queue &)=delete |
| queue (queue &&other) noexcept | |
| Move constructor. | |
| queue & | operator= (queue &&other) noexcept |
| Move assignment. | |
| void | send (const T &item) |
| Sends an item to the back of the queue, blocking indefinitely. | |
| template<typename Rep , typename Period > | |
| void | send (const T &item, const std::chrono::duration< Rep, Period > &timeout) |
| Sends an item to the back of the queue with a timeout. | |
| template<typename Clock , typename Duration > | |
| void | send_until (const T &item, const std::chrono::time_point< Clock, Duration > &deadline) |
| Sends an item to the back of the queue with a deadline. | |
| void | send_to_front (const T &item) |
| Sends an item to the front of the queue, blocking indefinitely. | |
| template<typename Rep , typename Period > | |
| void | send_to_front (const T &item, const std::chrono::duration< Rep, Period > &timeout) |
| Sends an item to the front of the queue with a timeout. | |
| template<typename Clock , typename Duration > | |
| void | send_to_front_until (const T &item, const std::chrono::time_point< Clock, Duration > &deadline) |
| Sends an item to the front of the queue with a deadline. | |
| result< void > | try_send (const T &item) |
| Sends an item to the back of the queue, blocking indefinitely. | |
| template<typename Rep , typename Period > | |
| result< void > | try_send (const T &item, const std::chrono::duration< Rep, Period > &timeout) |
| Sends an item to the back of the queue with a timeout. | |
| template<typename Clock , typename Duration > | |
| result< void > | try_send_until (const T &item, const std::chrono::time_point< Clock, Duration > &deadline) |
| Sends an item to the back of the queue with a deadline. | |
| result< void > | try_send_to_front (const T &item) |
| Sends an item to the front of the queue, blocking indefinitely. | |
| template<typename Rep , typename Period > | |
| result< void > | try_send_to_front (const T &item, const std::chrono::duration< Rep, Period > &timeout) |
| Sends an item to the front of the queue with a timeout. | |
| template<typename Clock , typename Duration > | |
| result< void > | try_send_to_front_until (const T &item, const std::chrono::time_point< Clock, Duration > &deadline) |
| Sends an item to the front of the queue with a deadline. | |
| void | overwrite (const T &item) noexcept |
| Overwrites the last item in the queue, or sends if the queue is not full. | |
| T | receive () |
| Receives an item from the queue, blocking indefinitely. | |
| template<typename Rep , typename Period > | |
| T | receive (const std::chrono::duration< Rep, Period > &timeout) |
| Receives an item from the queue with a timeout. | |
| template<typename Clock , typename Duration > | |
| T | receive_until (const std::chrono::time_point< Clock, Duration > &deadline) |
| Receives an item from the queue with a deadline. | |
| result< T > | try_receive () |
| Receives an item from the queue, blocking indefinitely. | |
| template<typename Rep , typename Period > | |
| result< T > | try_receive (const std::chrono::duration< Rep, Period > &timeout) |
| Receives an item from the queue with a timeout. | |
| template<typename Clock , typename Duration > | |
| result< T > | try_receive_until (const std::chrono::time_point< Clock, Duration > &deadline) |
| Receives an item from the queue with a deadline. | |
| T | peek () |
| Peeks at the front item in the queue without removing it, blocking indefinitely. | |
| template<typename Rep , typename Period > | |
| T | peek (const std::chrono::duration< Rep, Period > &timeout) |
| Peeks at the front item in the queue without removing it, with a timeout. | |
| template<typename Clock , typename Duration > | |
| T | peek_until (const std::chrono::time_point< Clock, Duration > &deadline) |
| Peeks at the front item in the queue without removing it, with a deadline. | |
| result< T > | try_peek () |
| Peeks at the front item in the queue without removing it, blocking indefinitely. | |
| template<typename Rep , typename Period > | |
| result< T > | try_peek (const std::chrono::duration< Rep, Period > &timeout) |
| Peeks at the front item in the queue without removing it, with a timeout. | |
| template<typename Clock , typename Duration > | |
| result< T > | try_peek_until (const std::chrono::time_point< Clock, Duration > &deadline) |
| Peeks at the front item in the queue without removing it, with a deadline. | |
| isr_send_result IRAM_ATTR | send_from_isr (const T &item) noexcept |
| Sends an item to the back of the queue from ISR context. | |
| isr_send_result IRAM_ATTR | send_to_front_from_isr (const T &item) noexcept |
| Sends an item to the front of the queue from ISR context. | |
| bool IRAM_ATTR | overwrite_from_isr (const T &item) noexcept |
| Overwrites the last item in the queue from ISR context. | |
| isr_receive_result IRAM_ATTR | receive_from_isr () noexcept |
| Receives an item from the queue in ISR context. | |
| std::optional< T > IRAM_ATTR | peek_from_isr () const noexcept |
| Peeks at the front item in the queue from ISR context without removing it. | |
| size_t | size () const noexcept |
| Returns the number of items currently in the queue. | |
| size_t | available () const noexcept |
| Returns the number of free spaces in the queue. | |
| bool | empty () const noexcept |
| Checks if the queue is empty. | |
| bool | full () const noexcept |
| Checks if the queue is full. | |
| QueueHandle_t | idf_handle () const noexcept |
| Returns the underlying FreeRTOS queue handle. | |
| void | reset () noexcept |
| Removes all items from the queue. | |
Static Public Member Functions | |
| static result< queue > | make (size_t length, flags< memory_caps > mem_caps=memory_caps::dram) |
| Creates a queue with the specified capacity. | |
Type-safe inter-task message queue.
A fixed-size, FIFO message queue for passing messages between tasks and between ISRs and tasks. Messages are copied into and out of the queue by value.
This type is non-copyable and move-only. Result-returning methods on a moved-from object return errc::invalid_state. Simple accessors return default/null values.
| T | The message type. Must be trivially copyable. |
|
inlineexplicit |
Creates a queue with the specified capacity.
| length | Maximum number of items the queue can hold. |
| mem_caps | Memory capability flags for queue storage allocation. |
| std::system_error | with idfxx::errc::invalid_arg if length is 0. |
| std::bad_alloc | if memory allocation fails. |
Definition at line 79 of file queue.hpp.
References idfxx::invalid_arg, and idfxx::to_underlying().
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinestatic |
Creates a queue with the specified capacity.
| length | Maximum number of items the queue can hold. |
| mem_caps | Memory capability flags for queue storage allocation. |
| invalid_arg | length is 0. |
Definition at line 99 of file queue.hpp.
References idfxx::error(), idfxx::invalid_arg, and idfxx::to_underlying().
|
delete |
|
inlinenoexcept |
Overwrites the last item in the queue, or sends if the queue is not full.
If the queue is full, the most recently written item is overwritten. If the queue is not full, the item is added to the back. This is most useful with a queue of length 1 to implement a "latest value" mailbox.
This operation never blocks and always succeeds.
| item | The item to write. |
Overwrites the last item in the queue from ISR context.
If the queue is full, the most recently written item is overwritten. This operation always succeeds.
| item | The item to write. |
|
inline |
Peeks at the front item in the queue without removing it, blocking indefinitely.
Blocks until an item is available. The item remains in the queue after peeking.
| std::system_error | with idfxx::errc::timeout if the queue remains empty. |
Definition at line 480 of file queue.hpp.
References idfxx::queue< T >::try_peek(), and idfxx::unwrap().
Peeks at the front item in the queue without removing it, with a timeout.
Blocks until an item is available or the timeout expires. The item remains in the queue after peeking.
| Rep | The representation type of the duration. |
| Period | The period type of the duration. |
| timeout | Maximum time to wait for an item. |
| std::system_error | with idfxx::errc::timeout if the queue remains empty for the duration. |
Definition at line 497 of file queue.hpp.
References idfxx::timeout, idfxx::queue< T >::try_peek(), and idfxx::unwrap().
|
inlinenoexcept |
|
inline |
Peeks at the front item in the queue without removing it, with a deadline.
Blocks until an item is available or the deadline is reached. The item remains in the queue after peeking.
| Clock | The clock type. |
| Duration | The duration type of the time point. |
| deadline | The time point at which to stop waiting. |
| std::system_error | with idfxx::errc::timeout if the queue remains empty until the deadline. |
Definition at line 516 of file queue.hpp.
References idfxx::queue< T >::try_peek_until(), and idfxx::unwrap().
|
inline |
Receives an item from the queue, blocking indefinitely.
Blocks until an item is available.
| std::system_error | with idfxx::errc::timeout if the queue remains empty. |
Definition at line 381 of file queue.hpp.
References idfxx::queue< T >::try_receive(), and idfxx::unwrap().
Receives an item from the queue with a timeout.
Blocks until an item is available or the timeout expires.
| Rep | The representation type of the duration. |
| Period | The period type of the duration. |
| timeout | Maximum time to wait for an item. |
| std::system_error | with idfxx::errc::timeout if the queue remains empty for the duration. |
Definition at line 397 of file queue.hpp.
References idfxx::timeout, idfxx::queue< T >::try_receive(), and idfxx::unwrap().
|
inlinenoexcept |
Receives an item from the queue in ISR context.
|
inline |
Receives an item from the queue with a deadline.
Blocks until an item is available or the deadline is reached.
| Clock | The clock type. |
| Duration | The duration type of the time point. |
| deadline | The time point at which to stop waiting. |
| std::system_error | with idfxx::errc::timeout if the queue remains empty until the deadline. |
Definition at line 415 of file queue.hpp.
References idfxx::queue< T >::try_receive_until(), and idfxx::unwrap().
|
inlinenoexcept |
Sends an item to the back of the queue, blocking indefinitely.
Blocks until space is available in the queue.
| item | The item to send. |
| std::system_error | with idfxx::errc::timeout if the queue remains full. |
Definition at line 154 of file queue.hpp.
References idfxx::queue< T >::try_send(), and idfxx::unwrap().
|
inline |
Sends an item to the back of the queue with a timeout.
Blocks until space is available or the timeout expires.
| Rep | The representation type of the duration. |
| Period | The period type of the duration. |
| item | The item to send. |
| timeout | Maximum time to wait for space. |
| std::system_error | with idfxx::errc::timeout if the queue remains full for the duration. |
Definition at line 170 of file queue.hpp.
References idfxx::timeout, idfxx::queue< T >::try_send(), and idfxx::unwrap().
|
inlinenoexcept |
Sends an item to the back of the queue from ISR context.
| item | The item to send. |
Sends an item to the front of the queue, blocking indefinitely.
Blocks until space is available in the queue. The item is placed at the front, so it will be the next item received.
| item | The item to send. |
| std::system_error | with idfxx::errc::timeout if the queue remains full. |
Definition at line 202 of file queue.hpp.
References idfxx::queue< T >::try_send_to_front(), and idfxx::unwrap().
|
inline |
Sends an item to the front of the queue with a timeout.
Blocks until space is available or the timeout expires. The item is placed at the front, so it will be the next item received.
| Rep | The representation type of the duration. |
| Period | The period type of the duration. |
| item | The item to send. |
| timeout | Maximum time to wait for space. |
| std::system_error | with idfxx::errc::timeout if the queue remains full for the duration. |
Definition at line 219 of file queue.hpp.
References idfxx::timeout, idfxx::queue< T >::try_send_to_front(), and idfxx::unwrap().
|
inlinenoexcept |
Sends an item to the front of the queue from ISR context.
| item | The item to send. |
|
inline |
Sends an item to the front of the queue with a deadline.
Blocks until space is available or the deadline is reached. The item is placed at the front, so it will be the next item received.
| Clock | The clock type. |
| Duration | The duration type of the time point. |
| item | The item to send. |
| deadline | The time point at which to stop waiting. |
| std::system_error | with idfxx::errc::timeout if the queue remains full until the deadline. |
Definition at line 238 of file queue.hpp.
References idfxx::queue< T >::try_send_to_front_until(), and idfxx::unwrap().
|
inline |
Sends an item to the back of the queue with a deadline.
Blocks until space is available or the deadline is reached.
| Clock | The clock type. |
| Duration | The duration type of the time point. |
| item | The item to send. |
| deadline | The time point at which to stop waiting. |
| std::system_error | with idfxx::errc::timeout if the queue remains full until the deadline. |
Definition at line 188 of file queue.hpp.
References idfxx::queue< T >::try_send_until(), and idfxx::unwrap().
|
inlinenoexcept |
Peeks at the front item in the queue without removing it, blocking indefinitely.
Blocks until an item is available. The item remains in the queue after peeking.
| timeout | The queue remained empty. |
Definition at line 529 of file queue.hpp.
Referenced by idfxx::queue< T >::peek(), and idfxx::queue< T >::peek().
|
inline |
Peeks at the front item in the queue without removing it, with a timeout.
Blocks until an item is available or the timeout expires. The item remains in the queue after peeking.
| Rep | The representation type of the duration. |
| Period | The period type of the duration. |
| timeout | Maximum time to wait for an item. |
| timeout | The queue remained empty for the duration. |
Definition at line 544 of file queue.hpp.
References idfxx::chrono::ticks(), and idfxx::timeout.
|
inline |
Peeks at the front item in the queue without removing it, with a deadline.
Blocks until an item is available or the deadline is reached. The item remains in the queue after peeking.
| Clock | The clock type. |
| Duration | The duration type of the time point. |
| deadline | The time point at which to stop waiting. |
| timeout | The queue remained empty until the deadline. |
Definition at line 561 of file queue.hpp.
References idfxx::chrono::ticks().
Referenced by idfxx::queue< T >::peek_until().
Receives an item from the queue, blocking indefinitely.
Blocks until an item is available.
| timeout | The queue remained empty. |
Definition at line 428 of file queue.hpp.
Referenced by idfxx::queue< T >::receive(), and idfxx::queue< T >::receive().
|
inline |
Receives an item from the queue with a timeout.
Blocks until an item is available or the timeout expires.
| Rep | The representation type of the duration. |
| Period | The period type of the duration. |
| timeout | Maximum time to wait for an item. |
| timeout | The queue remained empty for the duration. |
Definition at line 442 of file queue.hpp.
References idfxx::chrono::ticks(), and idfxx::timeout.
|
inline |
Receives an item from the queue with a deadline.
Blocks until an item is available or the deadline is reached.
| Clock | The clock type. |
| Duration | The duration type of the time point. |
| deadline | The time point at which to stop waiting. |
| timeout | The queue remained empty until the deadline. |
Definition at line 458 of file queue.hpp.
References idfxx::chrono::ticks().
Referenced by idfxx::queue< T >::receive_until().
Sends an item to the back of the queue, blocking indefinitely.
Blocks until space is available in the queue.
| item | The item to send. |
| timeout | The queue remained full. |
Definition at line 252 of file queue.hpp.
Referenced by idfxx::queue< T >::send(), and idfxx::queue< T >::send().
|
inline |
Sends an item to the back of the queue with a timeout.
Blocks until space is available or the timeout expires.
| Rep | The representation type of the duration. |
| Period | The period type of the duration. |
| item | The item to send. |
| timeout | Maximum time to wait for space. |
| timeout | The queue remained full for the duration. |
Definition at line 267 of file queue.hpp.
References idfxx::chrono::ticks(), and idfxx::timeout.
Sends an item to the front of the queue, blocking indefinitely.
Blocks until space is available in the queue. The item is placed at the front, so it will be the next item received.
| item | The item to send. |
| timeout | The queue remained full. |
Definition at line 302 of file queue.hpp.
Referenced by idfxx::queue< T >::send_to_front(), and idfxx::queue< T >::send_to_front().
|
inline |
Sends an item to the front of the queue with a timeout.
Blocks until space is available or the timeout expires. The item is placed at the front, so it will be the next item received.
| Rep | The representation type of the duration. |
| Period | The period type of the duration. |
| item | The item to send. |
| timeout | Maximum time to wait for space. |
| timeout | The queue remained full for the duration. |
Definition at line 318 of file queue.hpp.
References idfxx::chrono::ticks(), and idfxx::timeout.
|
inline |
Sends an item to the front of the queue with a deadline.
Blocks until space is available or the deadline is reached. The item is placed at the front, so it will be the next item received.
| Clock | The clock type. |
| Duration | The duration type of the time point. |
| item | The item to send. |
| deadline | The time point at which to stop waiting. |
| timeout | The queue remained full until the deadline. |
Definition at line 337 of file queue.hpp.
References idfxx::chrono::ticks().
Referenced by idfxx::queue< T >::send_to_front_until().
|
inline |
Sends an item to the back of the queue with a deadline.
Blocks until space is available or the deadline is reached.
| Clock | The clock type. |
| Duration | The duration type of the time point. |
| item | The item to send. |
| deadline | The time point at which to stop waiting. |
| timeout | The queue remained full until the deadline. |
Definition at line 284 of file queue.hpp.
References idfxx::chrono::ticks().
Referenced by idfxx::queue< T >::send_until().