Subversion Repositories Kolibri OS

Rev

Rev 3482 | Rev 5270 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3482 Serge 1
#ifndef _LINUX_WORKQUEUE_H
2
#define _LINUX_WORKQUEUE_H
3
 
4
#include 
5
#include 
6
 
7
struct work_struct;
8
typedef void (*work_func_t)(struct work_struct *work);
9
 
10
/*
11
 * Workqueue flags and constants.  For details, please refer to
12
 * Documentation/workqueue.txt.
13
 */
14
enum {
15
    WQ_NON_REENTRANT    = 1 << 0, /* guarantee non-reentrance */
16
    WQ_UNBOUND          = 1 << 1, /* not bound to any cpu */
17
    WQ_FREEZABLE        = 1 << 2, /* freeze during suspend */
18
    WQ_MEM_RECLAIM      = 1 << 3, /* may be used for memory reclaim */
19
    WQ_HIGHPRI          = 1 << 4, /* high priority */
20
    WQ_CPU_INTENSIVE    = 1 << 5, /* cpu instensive workqueue */
21
 
22
    WQ_DRAINING         = 1 << 6, /* internal: workqueue is draining */
23
    WQ_RESCUER          = 1 << 7, /* internal: workqueue has rescuer */
24
 
25
    WQ_MAX_ACTIVE       = 512,    /* I like 512, better ideas? */
26
    WQ_MAX_UNBOUND_PER_CPU  = 4,      /* 4 * #cpus for unbound wq */
27
    WQ_DFL_ACTIVE       = WQ_MAX_ACTIVE / 2,
28
};
29
 
30
 
31
struct workqueue_struct {
32
    spinlock_t lock;
33
    struct list_head worklist;
34
    struct list_head delayed_worklist;
35
};
36
 
37
struct work_struct {
38
    struct list_head entry;
39
    struct workqueue_struct *data;
40
    work_func_t func;
41
};
42
 
43
struct delayed_work {
44
    struct work_struct work;
45
    unsigned int delay;
46
};
47
 
48
static inline struct delayed_work *to_delayed_work(struct work_struct *work)
49
{
50
    return container_of(work, struct delayed_work, work);
51
}
52
 
53
extern struct workqueue_struct *system_wq;
54
 
55
void run_workqueue(struct workqueue_struct *cwq);
56
 
57
struct workqueue_struct *alloc_workqueue_key(const char *fmt,
58
                           unsigned int flags, int max_active);
59
 
60
 
61
#define alloc_ordered_workqueue(fmt, flags, args...)            \
62
        alloc_workqueue(fmt, WQ_UNBOUND | (flags), 1, ##args)
63
 
4125 Serge 64
bool queue_work(struct workqueue_struct *wq, struct work_struct *work);
3482 Serge 65
int queue_delayed_work(struct workqueue_struct *wq,
66
                        struct delayed_work *dwork, unsigned long delay);
67
 
68
bool schedule_delayed_work(struct delayed_work *dwork, unsigned long delay);
69
 
70
 
71
#define INIT_WORK(_work, _func)                 \
72
    do {                                        \
73
        INIT_LIST_HEAD(&(_work)->entry);        \
74
        (_work)->func = _func;                  \
75
    } while (0)
76
 
77
 
78
#define INIT_DELAYED_WORK(_work, _func)         \
79
    do {                                        \
80
        INIT_LIST_HEAD(&(_work)->work.entry);   \
81
        (_work)->work.func = _func;             \
82
    } while (0)
83
 
4125 Serge 84
static inline bool schedule_work(struct work_struct *work)
85
{
86
    return queue_work(system_wq, work);
87
}
3482 Serge 88
 
89
 
90
#endif  /*  _LINUX_WORKQUEUE_H  */