prio_queue.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #ifndef __PRIO_QUEUE_H__
  2. #define __PRIO_QUEUE_H__
  3. #include <rtthread.h>
  4. #define RT_PRIO_QUEUE_PRIO_MAX 32
  5. struct rt_prio_queue_item;
  6. struct rt_prio_queue {
  7. rt_uint32_t bitmap;
  8. struct rt_prio_queue_item *head[RT_PRIO_QUEUE_PRIO_MAX];
  9. struct rt_prio_queue_item *tail[RT_PRIO_QUEUE_PRIO_MAX];
  10. /* push thread suspend on the mempool, not queue */
  11. rt_list_t suspended_pop_list;
  12. rt_size_t item_sz;
  13. struct rt_mempool pool;
  14. };
  15. rt_err_t rt_prio_queue_init(struct rt_prio_queue *que,
  16. const char *name,
  17. void *buf,
  18. rt_size_t bufsz,
  19. rt_size_t itemsz);
  20. void rt_prio_queue_detach(struct rt_prio_queue *que);
  21. rt_err_t rt_prio_queue_push(struct rt_prio_queue *que,
  22. rt_uint8_t prio,
  23. void *data,
  24. rt_int32_t timeout);
  25. rt_err_t rt_prio_queue_pop(struct rt_prio_queue *que,
  26. void *data,
  27. rt_int32_t timeout);
  28. #ifdef RT_USING_HEAP
  29. struct rt_prio_queue* rt_prio_queue_create(const char *name,
  30. rt_size_t item_nr,
  31. rt_size_t item_sz);
  32. void rt_prio_queue_delete(struct rt_prio_queue *que);
  33. #endif
  34. void rt_prio_queue_dump(struct rt_prio_queue *que);
  35. #endif /* end of include guard: __PRIO_QUEUE_H__ */