aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/workqueue.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/linux/workqueue.h
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'include/linux/workqueue.h')
-rw-r--r--include/linux/workqueue.h90
1 files changed, 90 insertions, 0 deletions
diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
new file mode 100644
index 000000000000..ff46f537ba9b
--- /dev/null
+++ b/include/linux/workqueue.h
@@ -0,0 +1,90 @@
1/*
2 * workqueue.h --- work queue handling for Linux.
3 */
4
5#ifndef _LINUX_WORKQUEUE_H
6#define _LINUX_WORKQUEUE_H
7
8#include <linux/timer.h>
9#include <linux/linkage.h>
10#include <linux/bitops.h>
11
12struct workqueue_struct;
13
14struct work_struct {
15 unsigned long pending;
16 struct list_head entry;
17 void (*func)(void *);
18 void *data;
19 void *wq_data;
20 struct timer_list timer;
21};
22
23#define __WORK_INITIALIZER(n, f, d) { \
24 .entry = { &(n).entry, &(n).entry }, \
25 .func = (f), \
26 .data = (d), \
27 .timer = TIMER_INITIALIZER(NULL, 0, 0), \
28 }
29
30#define DECLARE_WORK(n, f, d) \
31 struct work_struct n = __WORK_INITIALIZER(n, f, d)
32
33/*
34 * initialize a work-struct's func and data pointers:
35 */
36#define PREPARE_WORK(_work, _func, _data) \
37 do { \
38 (_work)->func = _func; \
39 (_work)->data = _data; \
40 } while (0)
41
42/*
43 * initialize all of a work-struct:
44 */
45#define INIT_WORK(_work, _func, _data) \
46 do { \
47 INIT_LIST_HEAD(&(_work)->entry); \
48 (_work)->pending = 0; \
49 PREPARE_WORK((_work), (_func), (_data)); \
50 init_timer(&(_work)->timer); \
51 } while (0)
52
53extern struct workqueue_struct *__create_workqueue(const char *name,
54 int singlethread);
55#define create_workqueue(name) __create_workqueue((name), 0)
56#define create_singlethread_workqueue(name) __create_workqueue((name), 1)
57
58extern void destroy_workqueue(struct workqueue_struct *wq);
59
60extern int FASTCALL(queue_work(struct workqueue_struct *wq, struct work_struct *work));
61extern int FASTCALL(queue_delayed_work(struct workqueue_struct *wq, struct work_struct *work, unsigned long delay));
62extern void FASTCALL(flush_workqueue(struct workqueue_struct *wq));
63
64extern int FASTCALL(schedule_work(struct work_struct *work));
65extern int FASTCALL(schedule_delayed_work(struct work_struct *work, unsigned long delay));
66
67extern int schedule_delayed_work_on(int cpu, struct work_struct *work, unsigned long delay);
68extern void flush_scheduled_work(void);
69extern int current_is_keventd(void);
70extern int keventd_up(void);
71
72extern void init_workqueues(void);
73void cancel_rearming_delayed_work(struct work_struct *work);
74
75/*
76 * Kill off a pending schedule_delayed_work(). Note that the work callback
77 * function may still be running on return from cancel_delayed_work(). Run
78 * flush_scheduled_work() to wait on it.
79 */
80static inline int cancel_delayed_work(struct work_struct *work)
81{
82 int ret;
83
84 ret = del_timer_sync(&work->timer);
85 if (ret)
86 clear_bit(0, &work->pending);
87 return ret;
88}
89
90#endif