Subversion Repositories Kolibri OS

Rev

Rev 4125 | Go to most recent revision | Details | 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
 
64
int queue_delayed_work(struct workqueue_struct *wq,
65
                        struct delayed_work *dwork, unsigned long delay);
66
 
67
bool schedule_delayed_work(struct delayed_work *dwork, unsigned long delay);
68
 
69
 
70
#define INIT_WORK(_work, _func)                 \
71
    do {                                        \
72
        INIT_LIST_HEAD(&(_work)->entry);        \
73
        (_work)->func = _func;                  \
74
    } while (0)
75
 
76
 
77
#define INIT_DELAYED_WORK(_work, _func)         \
78
    do {                                        \
79
        INIT_LIST_HEAD(&(_work)->work.entry);   \
80
        (_work)->work.func = _func;             \
81
    } while (0)
82
 
83
 
84
 
85
#endif  /*  _LINUX_WORKQUEUE_H  */