VSF Documented
workqueue.h
Go to the documentation of this file.
1#ifndef __VSF_LINUX_WORKQUEUE_H__
2#define __VSF_LINUX_WORKQUEUE_H__
3
4#include "kernel/vsf_kernel.h"
5#include <linux/list.h>
6
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11struct workqueue_struct;
12struct work_struct;
13typedef void (*work_func_t)(struct work_struct *work);
14
18
22};
23
27};
28
29extern struct workqueue_struct *system_wq;
30
31extern struct workqueue_struct * alloc_workqueue(const char *fmt, unsigned int flags, int max_active, ...);
32extern void destroy_workqueue(struct workqueue_struct *wq);
33extern bool queue_delayed_work(struct workqueue_struct *wq, struct delayed_work *dwork, unsigned long delay);
34extern bool mod_delayed_work(struct workqueue_struct *wq, struct delayed_work *dwork, unsigned long delay);
35extern bool queue_work(struct workqueue_struct *wq, struct work_struct *work);
36extern void flush_workqueue(struct workqueue_struct *wq);
37
38#define INIT_WORK(__WORK, __FUNC) \
39 do { \
40 (__WORK)->func = (__FUNC); \
41 vsf_dlist_init_node(struct work_struct, entry, (__WORK)); \
42 } while (0)
43#define INIT_DELAYED_WORK(__DWORK, __FUNC) INIT_WORK(&(__DWORK)->work, (__FUNC))
44#define alloc_ordered_workqueue(__fmt, __flags, ...) \
45 alloc_workqueue(__fmt, __flags, 1, ##__VA_ARGS__)
46#define create_singlethread_workqueue(__name) \
47 alloc_ordered_workqueue("%s", 0, (__name))
48#define create_workqueue(__name) \
49 alloc_workqueue("%s", 0, 1, (__name))
50
51static inline struct delayed_work *to_delayed_work(struct work_struct *work)
52{
53 return vsf_container_of(work, struct delayed_work, work);
54}
55static inline bool schedule_work(struct work_struct *work)
56{
57 return queue_work(system_wq, work);
58}
59
60static inline bool schedule_delayed_work(struct delayed_work *dwork, unsigned long delay)
61{
62 return queue_delayed_work(system_wq, dwork, delay);
63}
64
65extern bool flush_work(struct work_struct *work);
66extern bool cancel_work(struct work_struct *work);
67extern bool cancel_work_sync(struct work_struct *work);
68
69extern bool flush_delayed_work(struct delayed_work *dwork);
70extern bool cancel_delayed_work(struct delayed_work *dwork);
71extern bool cancel_delayed_work_sync(struct delayed_work *dwork);
72
73#ifdef __cplusplus
74}
75#endif
76
77#endif
#define vsf_container_of(__ptr, __type, __member)
Definition __type.h:164
Definition vsf_eda.h:766
uint64_t vsf_systimer_tick_t
Definition cortex_a_generic.h:73
Definition workqueue.h:24
vsf_systimer_tick_t start_tick
Definition workqueue.h:26
struct work_struct work
Definition workqueue.h:25
Definition vsf_list.h:888
Definition workqueue.h:15
vsf_eda_t * __pending_eda
Definition workqueue.h:21
struct workqueue_struct * __wq
Definition workqueue.h:19
work_func_t func
Definition workqueue.h:17
vsf_dlist_node_t entry
Definition workqueue.h:16
bool __is_running
Definition workqueue.h:20
Definition vsf_linux_core.c:129
bool queue_delayed_work(struct workqueue_struct *wq, struct delayed_work *dwork, unsigned long delay)
Definition vsf_linux_core.c:282
bool cancel_delayed_work(struct delayed_work *dwork)
Definition vsf_linux_core.c:421
struct workqueue_struct * alloc_workqueue(const char *fmt, unsigned int flags, int max_active,...)
Definition vsf_linux_core.c:232
struct workqueue_struct * system_wq
Definition vsf_linux_core.c:143
bool mod_delayed_work(struct workqueue_struct *wq, struct delayed_work *dwork, unsigned long delay)
Definition vsf_linux_core.c:304
bool flush_work(struct work_struct *work)
Definition vsf_linux_core.c:342
void(* work_func_t)(struct work_struct *work)
Definition workqueue.h:13
void destroy_workqueue(struct workqueue_struct *wq)
Definition vsf_linux_core.c:259
bool cancel_delayed_work_sync(struct delayed_work *dwork)
Definition vsf_linux_core.c:431
void flush_workqueue(struct workqueue_struct *wq)
Definition vsf_linux_core.c:324
bool cancel_work(struct work_struct *work)
Definition vsf_linux_core.c:396
bool flush_delayed_work(struct delayed_work *dwork)
Definition vsf_linux_core.c:416
bool queue_work(struct workqueue_struct *wq, struct work_struct *work)
Definition vsf_linux_core.c:266
bool cancel_work_sync(struct work_struct *work)
Definition vsf_linux_core.c:406