1
0
Fork 0
forked from len0rd/rockbox

kernel: Add queue_full() API call

This allows callers to see if it's safe to enqueue something instead
of triggering a panic if the queue turns out to be full.

Change-Id: Idb887e7a47cfbfef998f27d9d85090f3c0ed2230
This commit is contained in:
Solomon Peachy 2024-10-06 11:15:58 -04:00
parent 2f3b9ab68a
commit d13029ebdd
2 changed files with 7 additions and 0 deletions

View file

@ -141,6 +141,7 @@ extern void queue_reply(struct event_queue *q, intptr_t retval);
extern bool queue_in_queue_send(struct event_queue *q);
#endif /* HAVE_EXTENDED_MESSAGING_AND_NAME */
extern bool queue_empty(const struct event_queue* q);
extern bool queue_full(const struct event_queue* q);
extern bool queue_peek(struct event_queue *q, struct queue_event *ev);
#define QPEEK_FILTER_COUNT_MASK (0xffu) /* 0x00=1 filter, 0xff=256 filters */

View file

@ -701,6 +701,12 @@ bool queue_empty(const struct event_queue* q)
return ( q->read == q->write );
}
/* Poll queue to see if it is full */
bool queue_full(const struct event_queue* q)
{
return ((q->write - q->read) >= QUEUE_LENGTH);
}
void queue_clear(struct event_queue* q)
{
int oldlevel;