|
oveRTOS C++ API
C++20 RAII wrappers for the oveRTOS C API
|
RAII wrapper around an oveRTOS typed message queue. More...
#include <queue.hpp>
Public Member Functions | |
| Queue () | |
| Constructs and initialises the queue. | |
| ~Queue () noexcept | |
| Destroys the queue, releasing the underlying kernel resource. | |
| Queue (const Queue &)=delete | |
| Queue & | operator= (const Queue &)=delete |
| Queue (Queue &&other) noexcept | |
| Move constructor — transfers ownership of the kernel handle. | |
| Queue & | operator= (Queue &&other) noexcept |
| Move-assignment operator — transfers ownership of the kernel handle. | |
| void | send (const T &item) |
| Sends an item to the back of the queue, blocking indefinitely. | |
| bool | try_send (const T &item) |
| Non-blocking send. | |
| template<class Rep , class Period > | |
| Result< void > | try_send_for (const T &item, const std::chrono::duration< Rep, Period > &rel) noexcept |
| Bounded-wait send. | |
| template<class Clock , class Duration > | |
| Result< void > | try_send_until (const T &item, const std::chrono::time_point< Clock, Duration > &deadline) noexcept |
| Deadline-based send templated over the clock. See Mutex::try_lock_until for the templated-clock rationale. | |
| void | receive (T &out) |
| Receives an item from the front of the queue, blocking indefinitely. | |
| bool | try_receive (T &out) |
| Non-blocking receive. | |
| template<class Rep , class Period > | |
| Result< void > | try_receive_for (T &out, const std::chrono::duration< Rep, Period > &rel) noexcept |
| Bounded-wait receive. | |
| template<class Clock , class Duration > | |
| Result< void > | try_receive_until (T &out, const std::chrono::time_point< Clock, Duration > &deadline) noexcept |
| Deadline-based receive templated over the clock. | |
| Result< void > | send_from_isr (const T &item) noexcept |
| Sends an item to the queue from an ISR context (non-blocking). | |
| Result< void > | receive_from_isr (T &out) noexcept |
| Receives an item from the queue from an ISR context (non-blocking). | |
| bool | valid () const |
Returns true if the underlying kernel handle is non-null. | |
| ove_queue_t | handle () const |
| Returns the raw oveRTOS queue handle. | |
RAII wrapper around an oveRTOS typed message queue.
Queue<T, MaxItems> stores items of type T in a FIFO buffer. Items are copied into the queue on send() and out of it on receive(), so T must be trivially copyable (or at least safe to copy via memcpy).
In zero-heap mode MaxItems must be greater than zero; the backing buffer is allocated inside the wrapper. On heap-enabled builds MaxItems is also required at compile time (it is passed to the kernel at construction).
| T | Type of message items; should be trivially copyable. |
| MaxItems | Compile-time capacity of the queue (must be > 0). |
|
inline |
Constructs and initialises the queue.
Only participates in overload resolution when MaxItems > 0. Asserts at startup if initialisation fails.
|
inlinenoexcept |
Move constructor — transfers ownership of the kernel handle.
| other | The source; its handle is set to null after the move. |
|
inlinenoexcept |
Move-assignment operator — transfers ownership of the kernel handle.
| other | The source; its handle is set to null after the move. |
|
inline |
Sends an item to the back of the queue, blocking indefinitely.
Forever-wait form: failure means the handle is unusable. Aborts via OVE_STATIC_INIT_ASSERT (same pattern as Mutex::lock, Semaphore::acquire).
|
inline |
Non-blocking send.
true on success, false if the queue was full.
|
inlinenoexcept |
Bounded-wait send.
| [in] | item | The item to enqueue (copied into the queue). |
| [in] | rel | Relative timeout (any std::chrono::duration unit). |
Result<void> on success; unexpected Error::QueueFull / Error::Timeout if the queue stayed full through the deadline; unexpected with another Error value on backend failure.
|
inlinenoexcept |
Deadline-based send templated over the clock. See Mutex::try_lock_until for the templated-clock rationale.
Result<void> with the appropriate Error on timeout / backend failure.
|
inline |
Receives an item from the front of the queue, blocking indefinitely.
Forever-wait form: failure means the handle is unusable. Aborts via OVE_STATIC_INIT_ASSERT.
| [out] | out | Reference to storage for the received item. |
|
inline |
Non-blocking receive.
true on success, false if the queue was empty.
|
inlinenoexcept |
Bounded-wait receive.
| [out] | out | Reference to storage for the received item. |
| [in] | rel | Relative timeout (any std::chrono::duration unit). |
Result<void> on success (item written to out); unexpected Error::QueueEmpty / Error::Timeout if the queue stayed empty through the deadline; unexpected with another Error value on backend failure.
|
inlinenoexcept |
Deadline-based receive templated over the clock.
|
inlinenoexcept |
Sends an item to the queue from an ISR context (non-blocking).
| [in] | item | The item to enqueue. |
Result<void> on success; unexpected Error::QueueFull if the queue was full; unexpected with another Error value on backend failure.
|
inlinenoexcept |
Receives an item from the queue from an ISR context (non-blocking).
| [out] | out | Reference to storage for the received item. |
Result<void> on success; unexpected Error::QueueEmpty if the queue was empty; unexpected with another Error value on backend failure.
|
inline |
Returns true if the underlying kernel handle is non-null.
true when the queue was successfully initialised.
|
inline |
Returns the raw oveRTOS queue handle.
ove_queue_t handle.