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:
Benjamin Walsh 2017-01-28 10:06:07 -05:00 committed by Anas Nashif
commit 39b80d8f29

View file

@ -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.
*