-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathwork.h
44 lines (34 loc) · 925 Bytes
/
work.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef __WORK_H
#define __WORK_H
#include <linux/list.h>
#include <clock.h>
struct work_struct {
struct list_head list;
uint64_t timeout;
bool delayed;
};
struct work_queue {
void (*fn)(struct work_struct *work);
void (*cancel)(struct work_struct *work);
struct list_head list;
struct list_head work;
};
static inline void wq_queue_work(struct work_queue *wq, struct work_struct *work)
{
work->delayed = false;
list_add_tail(&work->list, &wq->work);
}
static inline void wq_queue_delayed_work(struct work_queue *wq,
struct work_struct *work,
uint64_t delay_ns)
{
work->timeout = get_time_ns() + delay_ns;
work->delayed = true;
list_add_tail(&work->list, &wq->work);
}
void wq_register(struct work_queue *wq);
void wq_unregister(struct work_queue *wq);
void wq_do_all_works(void);
void wq_cancel_work(struct work_queue *wq);
#endif /* __WORK_H */