From fe74ae7b9b1f7c4ca203deabab4cdd17ff44d12d Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Mon, 11 Aug 2025 04:45:50 -0400 Subject: kernel: workqueue: Fixup passing of 'func' in wq This commit includes several changes: - Improves documentation in sys/workqueue.h - Removes useless 'func' field in workqueue structure - Duplicate strings and introduce work_destroy() Signed-off-by: Ian Moffett --- sys/include/sys/workqueue.h | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'sys/include/sys/workqueue.h') diff --git a/sys/include/sys/workqueue.h b/sys/include/sys/workqueue.h index 478751d..9925f79 100644 --- a/sys/include/sys/workqueue.h +++ b/sys/include/sys/workqueue.h @@ -50,12 +50,18 @@ typedef void(*workfunc_t)(struct workqueue *wqp, struct work *wp); * Represents work that may be added to a * workqueue. * - * @name: Name of this work/task - * @func: Function with work to be done - * @cookie: Used for validating the work structure + * @name: Name of this work/task [i] + * @data: Optional data to be passed with work [p] + * @func: Function with work to be done [p] + * @cookie: Used for validating the work structure [i] + * + * Field attributes: + * - [i]: Used internally + * - [p]: Used as parameter */ struct work { - const char *name; + char *name; + void *data; workfunc_t func; TAILQ_ENTRY(work) link; }; @@ -81,16 +87,15 @@ struct workqueue { size_t max_work; ssize_t nwork; uint16_t cookie; - workfunc_t func; struct proc *worktd; struct mutex *lock; }; -struct workqueue *workqueue_new(const char *name, workfunc_t func, - size_t max_work, int ipl); +struct workqueue *workqueue_new(const char *name, size_t max_work, int ipl); -int workqueue_enq(struct workqueue *wqp, struct work *wp); +int workqueue_enq(struct workqueue *wqp, const char *name, struct work *wp); int workqueue_destroy(struct workqueue *wqp); +int work_destroy(struct work *wp); #endif /* !_KERNEL */ #endif /* !_SYS_WORKQUEUE_H_ */ -- cgit v1.2.3