1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

core/mbox: add mbox_size() and mbox_avail()

This commit is contained in:
Kaspar Schleiser 2020-11-20 10:30:17 +01:00
parent 63af227f01
commit 91111555a6

View File

@ -159,6 +159,32 @@ static inline int mbox_try_get(mbox_t *mbox, msg_t *msg)
return _mbox_get(mbox, msg, NON_BLOCKING);
}
/**
* @brief Get mbox queue size (capacity)
*
* @param[in] mbox ptr to mailbox to operate on
*
* @return size of mbox queue (or 0 if there's no queue)
*/
static inline size_t mbox_size(mbox_t *mbox)
{
return mbox->cib.mask ? mbox->cib.mask + 1 : 0;
}
/**
* @brief Get messages available in mbox
*
* Returns the number of messages that can be retrieved without blocking.
*
* @param[in] mbox ptr to mailbox to operate on
*
* @return number of available messages
*/
static inline size_t mbox_avail(mbox_t *mbox)
{
return cib_avail(&mbox->cib);
}
#ifdef __cplusplus
}
#endif