1 /* 2 * COPYRIGHT (C) 2018, Real-Thread Information Technology Ltd 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Change Logs: 7 * Date Author Notes 8 * 2013-11-04 Grissiom add comment 9 */ 10 11 #ifndef __PRIO_QUEUE_H__ 12 #define __PRIO_QUEUE_H__ 13 14 #include <rtthread.h> 15 16 #define RT_PRIO_QUEUE_PRIO_MAX 32 17 18 struct rt_prio_queue_item; 19 20 struct rt_prio_queue { 21 rt_uint32_t bitmap; 22 struct rt_prio_queue_item *head[RT_PRIO_QUEUE_PRIO_MAX]; 23 struct rt_prio_queue_item *tail[RT_PRIO_QUEUE_PRIO_MAX]; 24 /* push thread suspend on the mempool, not queue */ 25 rt_list_t suspended_pop_list; 26 rt_size_t item_sz; 27 28 struct rt_mempool pool; 29 }; 30 31 rt_err_t rt_prio_queue_init(struct rt_prio_queue *que, 32 const char *name, 33 void *buf, 34 rt_size_t bufsz, 35 rt_size_t itemsz); 36 void rt_prio_queue_detach(struct rt_prio_queue *que); 37 38 rt_err_t rt_prio_queue_push(struct rt_prio_queue *que, 39 rt_uint8_t prio, 40 void *data, 41 rt_int32_t timeout); 42 rt_err_t rt_prio_queue_pop(struct rt_prio_queue *que, 43 void *data, 44 rt_int32_t timeout); 45 #ifdef RT_USING_HEAP 46 struct rt_prio_queue* rt_prio_queue_create(const char *name, 47 rt_size_t item_nr, 48 rt_size_t item_sz); 49 void rt_prio_queue_delete(struct rt_prio_queue *que); 50 #endif 51 52 void rt_prio_queue_dump(struct rt_prio_queue *que); 53 54 #endif /* end of include guard: __PRIO_QUEUE_H__ */ 55