mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-23 17:24:44 +00:00
freertos/ringbuf: Add an API xRingbufferGetCurFreeSize() to fetch current free size available
The earlier available API (xRingbufferGetMaxItemSize())just gives a static max entry value possible for given ring buffer. There was a feature request for an API which could provide a real time available buffer size. See below: https://github.com/espressif/esp-idf/issues/806 Signed-off-by: Piyush Shah <piyush@espressif.com>
This commit is contained in:
@@ -94,6 +94,21 @@ void vRingbufferDelete(RingbufHandle_t ringbuf);
|
||||
*/
|
||||
size_t xRingbufferGetMaxItemSize(RingbufHandle_t ringbuf);
|
||||
|
||||
/**
|
||||
* @brief Get current free size available in the buffer
|
||||
*
|
||||
* This gives the real time free space available in the ring buffer. So basically,
|
||||
* this will be the maximum size of the entry that can be sent into the buffer.
|
||||
*
|
||||
* @note This API is not thread safe. So, if multiple threads are accessing the same
|
||||
* ring buffer, it is the application's responsibility to ensure atomic access to this
|
||||
* API and the subsequent Send
|
||||
*
|
||||
* @param ringbuf - Ring buffer to query
|
||||
*
|
||||
* @return Current free size, in bytes, available for an entry
|
||||
*/
|
||||
size_t xRingbufferGetCurFreeSize(RingbufHandle_t ringbuf);
|
||||
|
||||
/**
|
||||
* @brief Insert an item into the ring buffer
|
||||
|
Reference in New Issue
Block a user