oveRTOS C API
Embedded RTOS framework — build system, configuration, and portable C API
Loading...
Searching...
No Matches
workqueue.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2026 Kamil Lulko <kamil.lulko@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 *
6 * This file is part of oveRTOS.
7 */
8
34#ifndef OVE_WORKQUEUE_H
35#define OVE_WORKQUEUE_H
36
37#include "ove/types.h"
38#include "ove/thread.h"
39#include "ove_config.h"
40
41#ifdef __cplusplus
42extern "C" {
43#endif
44
54typedef void (*ove_work_fn)(ove_work_t work);
55
56#include "ove/storage.h"
57
58#ifdef CONFIG_OVE_WORKQUEUE
59
76int ove_workqueue_init(ove_workqueue_t *wq, ove_workqueue_storage_t *storage, const char *name,
77 ove_prio_t priority, size_t stack_size, void *stack);
78
89
102int ove_work_init_static(ove_work_t *work, ove_work_storage_t *storage, ove_work_fn handler);
103
104#ifdef OVE_HEAP_WORKQUEUE
117
129#endif /* OVE_HEAP_WORKQUEUE */
130
144#ifdef OVE_HEAP_WORKQUEUE
145int ove_workqueue_create(ove_workqueue_t *wq, const char *name, ove_prio_t priority,
146 size_t stack_size);
147
158#endif /* OVE_HEAP_WORKQUEUE */
159
172
185int ove_work_submit_delayed(ove_workqueue_t wq, ove_work_t work, uint32_t delay_ms);
186
198
199#else /* !CONFIG_OVE_WORKQUEUE */
200
201/* P0-3: _init/_deinit stubs so OVE_WORKQUEUE_DEFINE_STATIC links cleanly
202 * when CONFIG_OVE_WORKQUEUE=n. */
203static inline int ove_workqueue_init(ove_workqueue_t *wq, ove_workqueue_storage_t *st,
204 const char *n, ove_prio_t p, size_t s, void *stack)
205{
206 (void)wq;
207 (void)st;
208 (void)n;
209 (void)p;
210 (void)s;
211 (void)stack;
213}
214static inline void ove_workqueue_deinit(ove_workqueue_t wq)
215{
216 (void)wq;
217}
218
219static inline int ove_workqueue_create(ove_workqueue_t *wq, const char *n, ove_prio_t p, size_t s)
220{
221 (void)wq;
222 (void)n;
223 (void)p;
224 (void)s;
226}
227static inline void ove_workqueue_destroy(ove_workqueue_t wq)
228{
229 (void)wq;
230}
231static inline int ove_work_init(ove_work_t *w, ove_work_fn h)
232{
233 (void)w;
234 (void)h;
236}
237static inline void ove_work_free(ove_work_t w)
238{
239 (void)w;
240}
241static inline int ove_work_submit(ove_workqueue_t wq, ove_work_t w)
242{
243 (void)wq;
244 (void)w;
246}
247static inline int ove_work_submit_delayed(ove_workqueue_t wq, ove_work_t w, uint32_t d)
248{
249 (void)wq;
250 (void)w;
251 (void)d;
253}
254static inline int ove_work_cancel(ove_work_t w)
255{
256 (void)w;
258}
259
260#endif /* CONFIG_OVE_WORKQUEUE */
261
262#ifdef __cplusplus
263}
264#endif
265
/* end of ove_workqueue group */
267
268#endif /* OVE_WORKQUEUE_H */
ove_prio_t
Portable thread-priority levels.
Definition thread.h:68
struct ove_workqueue * ove_workqueue_t
Opaque handle for a work queue object.
Definition types.h:226
struct ove_work * ove_work_t
Opaque handle for a deferred work item.
Definition types.h:229
@ OVE_ERR_NOT_SUPPORTED
Definition types.h:98
void ove_work_free(ove_work_t work)
Free a heap-allocated work item.
void ove_workqueue_destroy(ove_workqueue_t wq)
Destroy a heap-allocated work queue.
int ove_workqueue_create(ove_workqueue_t *wq, const char *name, ove_prio_t priority, size_t stack_size)
Allocate a heap-backed work queue.
int ove_work_init(ove_work_t *work, ove_work_fn handler)
Allocate and initialise a heap-backed work item.
int ove_work_submit(ove_workqueue_t wq, ove_work_t work)
Submit a work item for immediate execution on the work queue.
int ove_work_init_static(ove_work_t *work, ove_work_storage_t *storage, ove_work_fn handler)
Initialise a work item using caller-provided static storage.
int ove_workqueue_init(ove_workqueue_t *wq, ove_workqueue_storage_t *storage, const char *name, ove_prio_t priority, size_t stack_size, void *stack)
Initialise a work queue using caller-provided static storage.
int ove_work_cancel(ove_work_t work)
Cancel a pending work item before it executes.
void(* ove_work_fn)(ove_work_t work)
Prototype for a work item handler function.
Definition workqueue.h:54
int ove_work_submit_delayed(ove_workqueue_t wq, ove_work_t work, uint32_t delay_ms)
Submit a work item for execution after a delay.
void ove_workqueue_deinit(ove_workqueue_t wq)
Deinitialise a statically-allocated work queue.