kernel: add k_fifo_is_empty()
Allow peeking at the fifo to see if there is an element without dequeuing it. Change-Id: I99cbe4495c81f1d7b77ad6a37cef4ec8c24d48eb Signed-off-by: Benjamin Walsh <walsh.benj@gmail.com>
This commit is contained in:
parent
304c24825f
commit
39b80d8f29
1 changed files with 18 additions and 0 deletions
|
@ -1193,6 +1193,24 @@ extern void k_fifo_put_slist(struct k_fifo *fifo, sys_slist_t *list);
|
|||
*/
|
||||
extern void *k_fifo_get(struct k_fifo *fifo, int32_t timeout);
|
||||
|
||||
/**
|
||||
* @brief Query a fifo to see if it has data available.
|
||||
*
|
||||
* Note that the data might be already gone by the time this function returns
|
||||
* if other threads is also trying to read from the fifo.
|
||||
*
|
||||
* @note Can be called by ISRs.
|
||||
*
|
||||
* @param fifo Address of the fifo.
|
||||
*
|
||||
* @return Non-zero if the fifo is empty.
|
||||
* @return 0 if data is available.
|
||||
*/
|
||||
static inline int k_fifo_is_empty(struct k_fifo *fifo)
|
||||
{
|
||||
return (int)sys_slist_is_empty(&fifo->data_q);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Statically define and initialize a fifo.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue