RAII wrapper representing a single deferred work item.
More...
#include <workqueue.hpp>
|
template<typename F >
requires WorkHandler<F> |
| | Work (F handler) |
| | Constructs a work item with the given handler function.
|
| |
|
| ~Work () |
| | Destroys the work item, freeing its kernel resource (heap mode).
|
| |
|
| Work (const Work &)=delete |
| |
|
Work & | operator= (const Work &)=delete |
| |
| | Work (Work &&other) noexcept |
| | Move constructor — transfers ownership of the kernel handle.
|
| |
| Work & | operator= (Work &&other) noexcept |
| | Move-assignment operator — transfers ownership of the kernel handle.
|
| |
| template<size_t S> |
| int | submit (Workqueue< S > &wq) |
| | Submits the work item to a workqueue for immediate execution.
|
| |
| template<size_t S> |
| int | submit_delayed (Workqueue< S > &wq, uint32_t delay_ms) |
| | Submits the work item to a workqueue with a delay.
|
| |
| int | cancel () |
| | Attempts to cancel a pending work item.
|
| |
| bool | valid () const |
| | Returns true if the underlying kernel handle is non-null.
|
| |
| ove_work_t | handle () const |
| | Returns the raw oveRTOS work handle.
|
| |
RAII wrapper representing a single deferred work item.
A Work item encapsulates a handler function and can be submitted to a Workqueue for asynchronous or delayed execution. The same Work object must not be submitted while it is already pending or running.
- Note
- Not copyable. Move-only when heap allocation is enabled.
◆ Work() [1/2]
template<typename F >
requires WorkHandler<F>
| ove::Work::Work |
( |
F |
handler | ) |
|
|
inlineexplicit |
Constructs a work item with the given handler function.
- Template Parameters
-
| F | Handler type satisfying WorkHandler. |
- Parameters
-
| [in] | handler | Function pointer called when the work item is executed. |
Asserts at startup if initialisation fails.
◆ Work() [2/2]
| ove::Work::Work |
( |
Work && |
other | ) |
|
|
inlinenoexcept |
Move constructor — transfers ownership of the kernel handle.
- Parameters
-
| other | The source; its handle is set to null after the move. |
◆ operator=()
| Work & ove::Work::operator= |
( |
Work && |
other | ) |
|
|
inlinenoexcept |
Move-assignment operator — transfers ownership of the kernel handle.
- Parameters
-
| other | The source; its handle is set to null after the move. |
- Returns
- Reference to this object.
◆ submit()
Submits the work item to a workqueue for immediate execution.
- Template Parameters
-
| S | Stack size of the target workqueue. |
- Parameters
-
| [in] | wq | The workqueue to submit this work item to. |
- Returns
OVE_OK on success, or a negative error code.
◆ submit_delayed()
template<size_t S>
| int ove::Work::submit_delayed |
( |
Workqueue< S > & |
wq, |
|
|
uint32_t |
delay_ms |
|
) |
| |
|
inline |
Submits the work item to a workqueue with a delay.
- Template Parameters
-
| S | Stack size of the target workqueue. |
- Parameters
-
| [in] | wq | The workqueue to submit this work item to. |
| [in] | delay_ms | Delay in milliseconds before the item is executed. |
- Returns
OVE_OK on success, or a negative error code.
◆ cancel()
| int ove::Work::cancel |
( |
| ) |
|
|
inline |
Attempts to cancel a pending work item.
If the item is already running, cancellation may not be possible.
- Returns
OVE_OK if cancelled, or a negative error code.
◆ valid()
| bool ove::Work::valid |
( |
| ) |
const |
|
inline |
Returns true if the underlying kernel handle is non-null.
- Returns
true when the work item was successfully initialised.
◆ handle()
| ove_work_t ove::Work::handle |
( |
| ) |
const |
|
inline |
Returns the raw oveRTOS work handle.
- Returns
- The opaque
ove_work_t handle.
The documentation for this class was generated from the following file: