blob: 7eec17ad7fa195bba39c06e44817ef3f3a1b0402 [file] [log] [blame]
John Stultz1f5a2472010-12-09 12:02:18 -08001#ifndef _LINUX_TIMERQUEUE_H
2#define _LINUX_TIMERQUEUE_H
3
4#include <linux/rbtree.h>
5#include <linux/ktime.h>
6
7
8struct timerqueue_node {
9 struct rb_node node;
10 ktime_t expires;
11};
12
13struct timerqueue_head {
14 struct rb_root head;
15 struct timerqueue_node *next;
16};
17
18
Thomas Gleixnerc3206422015-04-14 21:08:46 +000019extern bool timerqueue_add(struct timerqueue_head *head,
20 struct timerqueue_node *node);
21extern bool timerqueue_del(struct timerqueue_head *head,
22 struct timerqueue_node *node);
John Stultz1f5a2472010-12-09 12:02:18 -080023extern struct timerqueue_node *timerqueue_iterate_next(
24 struct timerqueue_node *node);
25
Thomas Gleixner45f74262010-12-11 12:34:34 +010026/**
Lucas De Marchi25985ed2011-03-30 22:57:33 -030027 * timerqueue_getnext - Returns the timer with the earliest expiration time
Thomas Gleixner45f74262010-12-11 12:34:34 +010028 *
29 * @head: head of timerqueue
30 *
31 * Returns a pointer to the timer node that has the
32 * earliest expiration time.
33 */
34static inline
35struct timerqueue_node *timerqueue_getnext(struct timerqueue_head *head)
36{
37 return head->next;
38}
39
John Stultz1f5a2472010-12-09 12:02:18 -080040static inline void timerqueue_init(struct timerqueue_node *node)
41{
Michel Lespinasse4c199a92012-10-08 16:30:32 -070042 RB_CLEAR_NODE(&node->node);
John Stultz1f5a2472010-12-09 12:02:18 -080043}
44
45static inline void timerqueue_init_head(struct timerqueue_head *head)
46{
47 head->head = RB_ROOT;
48 head->next = NULL;
49}
50#endif /* _LINUX_TIMERQUEUE_H */