16#ifdef CONFIG_OVE_WORKQUEUE
18#include <ove/workqueue.h>
60 requires(StackSize > 0)
62#ifdef CONFIG_OVE_ZERO_HEAP
63 static_assert(StackSize > 0,
"StackSize must be > 0 in zero-heap mode");
64 int err = ove_workqueue_init(&handle_, &storage_, name, prio, StackSize, stack_);
66 int err = ove_workqueue_create(&handle_, name, prio, StackSize);
68 OVE_STATIC_INIT_ASSERT(err == OVE_OK);
78#ifdef CONFIG_OVE_ZERO_HEAP
79 ove_workqueue_deinit(handle_);
81 ove_workqueue_destroy(handle_);
88#ifdef CONFIG_OVE_ZERO_HEAP
98 other.handle_ =
nullptr;
108 if (
this != &other) {
110 ove_workqueue_destroy(handle_);
111 handle_ = other.handle_;
112 other.handle_ =
nullptr;
124 return handle_ !=
nullptr;
137 ove_workqueue_t handle_ =
nullptr;
138#ifdef CONFIG_OVE_ZERO_HEAP
139 ove_workqueue_storage_t storage_ = {};
140 OVE_THREAD_STACK_MEMBER_(stack_, StackSize > 0 ? StackSize : 1);
164 template <
typename F>
168#ifdef CONFIG_OVE_ZERO_HEAP
169 int err = ove_work_init_static(&handle_, &storage_, handler);
171 int err = ove_work_init(&handle_, handler);
173 OVE_STATIC_INIT_ASSERT(err == OVE_OK);
183#ifndef CONFIG_OVE_ZERO_HEAP
184 ove_work_free(handle_);
189 Work &operator=(
const Work &) =
delete;
191#ifdef CONFIG_OVE_ZERO_HEAP
199 Work(
Work &&other) noexcept : handle_(other.handle_)
201 other.handle_ =
nullptr;
211 if (
this != &other) {
213 ove_work_free(handle_);
214 handle_ = other.handle_;
215 other.handle_ =
nullptr;
230 return from_rc(ove_work_submit(wq.handle(), handle_));
244 return from_rc(ove_work_submit_delayed(wq.handle(), handle_, delay_ms));
257 return from_rc(ove_work_cancel(handle_));
266 return handle_ !=
nullptr;
279 ove_work_t handle_ =
nullptr;
280#ifdef CONFIG_OVE_ZERO_HEAP
281 ove_work_storage_t storage_ = {};
RAII wrapper representing a single deferred work item.
Definition workqueue.hpp:155
bool valid() const
Returns true if the underlying kernel handle is non-null.
Definition workqueue.hpp:264
Result< void > cancel() noexcept
Attempts to cancel a pending work item.
Definition workqueue.hpp:255
Work(Work &&other) noexcept
Move constructor — transfers ownership of the kernel handle.
Definition workqueue.hpp:199
Result< void > submit_delayed(Workqueue< S > &wq, uint32_t delay_ms) noexcept
Submits the work item to a workqueue with a delay.
Definition workqueue.hpp:242
Work & operator=(Work &&other) noexcept
Move-assignment operator — transfers ownership of the kernel handle.
Definition workqueue.hpp:209
~Work() noexcept
Destroys the work item, freeing its kernel resource (heap mode).
Definition workqueue.hpp:179
Work(F handler)
Constructs a work item with the given handler function.
Definition workqueue.hpp:165
ove_work_t handle() const
Returns the raw oveRTOS work handle.
Definition workqueue.hpp:273
Result< void > submit(Workqueue< S > &wq) noexcept
Submits the work item to a workqueue for immediate execution.
Definition workqueue.hpp:228
RAII wrapper around an oveRTOS workqueue (dedicated worker thread).
Definition workqueue.hpp:47
~Workqueue() noexcept
Destroys the workqueue and terminates the worker thread.
Definition workqueue.hpp:74
Workqueue(Workqueue &&other) noexcept
Move constructor — transfers ownership of the kernel handle.
Definition workqueue.hpp:96
bool valid() const
Returns true if the underlying kernel handle is non-null.
Definition workqueue.hpp:122
Workqueue(const char *name, ove_prio_t prio)
Constructs and starts the workqueue.
Definition workqueue.hpp:59
ove_workqueue_t handle() const
Returns the raw oveRTOS workqueue handle.
Definition workqueue.hpp:131
Workqueue & operator=(Workqueue &&other) noexcept
Move-assignment operator — transfers ownership of the kernel handle.
Definition workqueue.hpp:106
Concept satisfied by any callable convertible to ove_work_fn.
Definition workqueue.hpp:33
Strong ove::Error type, Result<T> alias, and std::error_code interop for the oveRTOS C++ binding.
Top-level namespace for all oveRTOS C++ abstractions.
Definition app.hpp:20
Result< void > from_rc(int rc) noexcept
Lifts a substrate rc-code into a Result<void>.
Definition error.hpp:254
std::expected< T, Error > Result
std::expected-based result alias.
Definition error.hpp:139
Common type definitions and concepts for the C++ wrapper layer.