|
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, memory_type mem_type=memory_type::internal) | |
| 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 &&)=delete | |
| queue & | operator= (queue &&)=delete |
| 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. | |
| void | try_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< std::unique_ptr< queue > > | make (size_t length, memory_type mem_type=memory_type::internal) |
| 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.
Queues are non-copyable and non-movable. Use the factory method make() for result-based construction or the throwing constructor when exceptions are enabled.
| 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_type | Memory region for queue storage allocation. |
| std::system_error | with idfxx::errc::invalid_arg if length is 0. |
| std::system_error | with idfxx::errc::no_mem if memory allocation fails. |
Definition at line 79 of file queue.hpp.
References idfxx::invalid_arg, and idfxx::no_mem.
|
inline |
|
delete |
|
delete |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinestatic |
Creates a queue with the specified capacity.
| length | Maximum number of items the queue can hold. |
| mem_type | Memory region for queue storage allocation. |
| invalid_arg | length is 0. |
| no_mem | Memory allocation failed. |
Definition at line 101 of file queue.hpp.
References idfxx::error(), idfxx::invalid_arg, and idfxx::no_mem.
|
delete |
|
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. |
Definition at line 352 of file queue.hpp.
References idfxx::queue< T >::try_overwrite().
|
inlinenoexcept |
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 481 of file queue.hpp.
References idfxx::queue< T >::try_peek(), and idfxx::unwrap().
|
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. |
| std::system_error | with idfxx::errc::timeout if the queue remains empty for the duration. |
Definition at line 498 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 517 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 382 of file queue.hpp.
References idfxx::queue< T >::try_receive(), and idfxx::unwrap().
|
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. |
| std::system_error | with idfxx::errc::timeout if the queue remains empty for the duration. |
Definition at line 398 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 416 of file queue.hpp.
References idfxx::queue< T >::try_receive_until(), and idfxx::unwrap().
|
inlinenoexcept |
|
inline |
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 144 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 160 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. |
|
inline |
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 192 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 209 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 228 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 178 of file queue.hpp.
References idfxx::queue< T >::try_send_until(), and idfxx::unwrap().
|
inlinenoexcept |
|
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. |
Definition at line 366 of file queue.hpp.
Referenced by idfxx::queue< T >::overwrite().
|
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.
| timeout | The queue remained empty. |
Definition at line 530 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 545 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 562 of file queue.hpp.
References idfxx::chrono::ticks().
Referenced by idfxx::queue< T >::peek_until().
|
inline |
Receives an item from the queue, blocking indefinitely.
Blocks until an item is available.
| timeout | The queue remained empty. |
Definition at line 429 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 443 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 459 of file queue.hpp.
References idfxx::chrono::ticks().
Referenced by idfxx::queue< T >::receive_until().
|
inline |
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 242 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 257 of file queue.hpp.
References idfxx::chrono::ticks(), and idfxx::timeout.
|
inline |
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 292 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 308 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 327 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 274 of file queue.hpp.
References idfxx::chrono::ticks().
Referenced by idfxx::queue< T >::send_until().