19#ifdef CONFIG_OVE_QUEUE
42template <
typename T,
size_t MaxItems = 0>
51 Queue()
requires (MaxItems > 0) {
52#ifdef CONFIG_OVE_ZERO_HEAP
53 static_assert(MaxItems > 0,
54 "MaxItems must be > 0 in zero-heap mode");
55 int err = ove_queue_init(&handle_, &storage_,
56 buffer_,
sizeof(T), MaxItems);
58 int err = ove_queue_create(&handle_,
sizeof(T), MaxItems);
60 OVE_STATIC_INIT_ASSERT(err == OVE_OK);
68#ifdef CONFIG_OVE_ZERO_HEAP
69 ove_queue_deinit(handle_);
71 ove_queue_destroy(handle_);
78#ifdef CONFIG_OVE_ZERO_HEAP
87 other.handle_ =
nullptr;
97 if (handle_) ove_queue_destroy(handle_);
98 handle_ = other.handle_;
99 other.handle_ =
nullptr;
112 [[nodiscard]]
int send(
const T &item,
113 uint32_t timeout_ms = OVE_WAIT_FOREVER) {
114 return ove_queue_send(handle_, &item, timeout_ms);
125 uint32_t timeout_ms = OVE_WAIT_FOREVER) {
126 return ove_queue_receive(handle_, item, timeout_ms);
135 return ove_queue_send_from_isr(handle_, &item);
144 return ove_queue_receive_from_isr(handle_, item);
151 bool valid()
const {
return handle_ !=
nullptr; }
157 ove_queue_t
handle()
const {
return handle_; }
160 ove_queue_t handle_ =
nullptr;
161#ifdef CONFIG_OVE_ZERO_HEAP
162 ove_queue_storage_t storage_ = {};
163 T buffer_[MaxItems > 0 ? MaxItems : 1];
RAII wrapper around an oveRTOS typed message queue.
Definition queue.hpp:43
int send_from_isr(const T &item)
Sends an item to the queue from an ISR context (non-blocking).
Definition queue.hpp:134
ove_queue_t handle() const
Returns the raw oveRTOS queue handle.
Definition queue.hpp:157
int receive_from_isr(T *item)
Receives an item from the queue from an ISR context (non-blocking).
Definition queue.hpp:143
Queue()
Constructs and initialises the queue.
Definition queue.hpp:51
~Queue()
Destroys the queue, releasing the underlying kernel resource.
Definition queue.hpp:66
Queue & operator=(Queue &&other) noexcept
Move-assignment operator — transfers ownership of the kernel handle.
Definition queue.hpp:95
Queue(Queue &&other) noexcept
Move constructor — transfers ownership of the kernel handle.
Definition queue.hpp:86
int receive(T *item, uint32_t timeout_ms=OVE_WAIT_FOREVER)
Receives an item from the front of the queue from task context.
Definition queue.hpp:124
int send(const T &item, uint32_t timeout_ms=OVE_WAIT_FOREVER)
Sends an item to the back of the queue from task context.
Definition queue.hpp:112
bool valid() const
Returns true if the underlying kernel handle is non-null.
Definition queue.hpp:151
Top-level namespace for all oveRTOS C++ abstractions.
Definition app.hpp:19
Common type definitions and concepts for the C++ wrapper layer.