1 #ifndef _LINUX_TIMERQUEUE_H
2 #define _LINUX_TIMERQUEUE_H
4 #include <linux/rbtree.h>
5 #include <linux/ktime.h>
8 struct timerqueue_node {
13 struct timerqueue_head {
14 struct rb_root_cached rb_root;
18 extern bool timerqueue_add(struct timerqueue_head *head,
19 struct timerqueue_node *node);
20 extern bool timerqueue_del(struct timerqueue_head *head,
21 struct timerqueue_node *node);
22 extern struct timerqueue_node *timerqueue_iterate_next(
23 struct timerqueue_node *node);
26 * timerqueue_getnext - Returns the timer with the earliest expiration time
28 * @head: head of timerqueue
30 * Returns a pointer to the timer node that has the earliest expiration time.
33 struct timerqueue_node *timerqueue_getnext(struct timerqueue_head *head)
35 struct rb_node *leftmost = rb_first_cached(&head->rb_root);
37 return rb_entry(leftmost, struct timerqueue_node, node);
40 static inline void timerqueue_init(struct timerqueue_node *node)
42 RB_CLEAR_NODE(&node->node);
45 static inline void timerqueue_init_head(struct timerqueue_head *head)
47 head->rb_root = RB_ROOT_CACHED;
49 #endif /* _LINUX_TIMERQUEUE_H */