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