timerqueue.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #ifndef _LINUX_TIMERQUEUE_H
  2. #define _LINUX_TIMERQUEUE_H
  3. #include <linux/rbtree.h>
  4. #include <linux/ktime.h>
  5. struct timerqueue_node {
  6. struct rb_node node;
  7. ktime_t expires;
  8. };
  9. struct timerqueue_head {
  10. struct rb_root head;
  11. struct timerqueue_node *next;
  12. };
  13. extern bool timerqueue_add(struct timerqueue_head *head,
  14. struct timerqueue_node *node);
  15. extern bool timerqueue_del(struct timerqueue_head *head,
  16. struct timerqueue_node *node);
  17. extern struct timerqueue_node *timerqueue_iterate_next(
  18. struct timerqueue_node *node);
  19. /**
  20. * timerqueue_getnext - Returns the timer with the earliest expiration time
  21. *
  22. * @head: head of timerqueue
  23. *
  24. * Returns a pointer to the timer node that has the
  25. * earliest expiration time.
  26. */
  27. static inline
  28. struct timerqueue_node *timerqueue_getnext(struct timerqueue_head *head)
  29. {
  30. return head->next;
  31. }
  32. static inline void timerqueue_init(struct timerqueue_node *node)
  33. {
  34. RB_CLEAR_NODE(&node->node);
  35. }
  36. static inline void timerqueue_init_head(struct timerqueue_head *head)
  37. {
  38. head->head = RB_ROOT;
  39. head->next = NULL;
  40. }
  41. #endif /* _LINUX_TIMERQUEUE_H */