Subversion Repositories shark

Rev

Rev 422 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
422 giacomo 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
 
11
struct workqueue_struct;
12
 
13
struct work_struct {
14
        unsigned long pending;
15
        struct list_head entry;
16
        void (*func)(void *);
17
        void *data;
18
        void *wq_data;
19
        struct timer_list timer;
20
};
21
 
22
#define __WORK_INITIALIZER(n, f, d) {                           \
23
        .entry  = { &(n).entry, &(n).entry },                   \
24
        .func = (f),                                            \
25
        .data = (d),                                            \
26
        .timer = TIMER_INITIALIZER(NULL, 0, 0),                 \
27
        }
28
 
29
#define DECLARE_WORK(n, f, d)                                   \
30
        struct work_struct n = __WORK_INITIALIZER(n, f, d)
31
 
32
/*
33
 * initialize a work-struct's func and data pointers:
34
 */
35
#define PREPARE_WORK(_work, _func, _data)                       \
36
        do {                                                    \
37
                (_work)->func = _func;                          \
38
                (_work)->data = _data;                          \
39
        } while (0)
40
 
41
/*
42
 * initialize all of a work-struct:
43
 */
44
#define INIT_WORK(_work, _func, _data)                          \
45
        do {                                                    \
46
                INIT_LIST_HEAD(&(_work)->entry);                \
47
                (_work)->pending = 0;                           \
48
                PREPARE_WORK((_work), (_func), (_data));        \
49
                init_timer(&(_work)->timer);                    \
50
        } while (0)
51
 
52
extern struct workqueue_struct *create_workqueue(const char *name);
53
extern void destroy_workqueue(struct workqueue_struct *wq);
54
 
55
extern int FASTCALL(queue_work(struct workqueue_struct *wq, struct work_struct *work));
56
extern int FASTCALL(queue_delayed_work(struct workqueue_struct *wq, struct work_struct *work, unsigned long delay));
57
extern void FASTCALL(flush_workqueue(struct workqueue_struct *wq));
58
 
59
extern int FASTCALL(schedule_work(struct work_struct *work));
60
extern int FASTCALL(schedule_delayed_work(struct work_struct *work, unsigned long delay));
61
extern void flush_scheduled_work(void);
62
extern int current_is_keventd(void);
63
 
64
extern void init_workqueues(void);
65
 
66
/*
67
 * Kill off a pending schedule_delayed_work().  Note that the work callback
68
 * function may still be running on return from cancel_delayed_work().  Run
69
 * flush_scheduled_work() to wait on it.
70
 */
71
static inline int cancel_delayed_work(struct work_struct *work)
72
{
73
        return del_timer_sync(&work->timer);
74
}
75
 
76
#endif
77