ring_buf
Loading...
Searching...
No Matches
Functions
Contiguous Ring Buffer Access

Functions for contiguous access to ring buffer data. More...

Collaboration diagram for Contiguous Ring Buffer Access:

Functions

ring_buf_size_t ring_buf_put_claim (struct ring_buf *buf, void **space, ring_buf_size_t size)
 Claims space for putting data into a ring buffer.
 
int ring_buf_put_ack (struct ring_buf *buf, ring_buf_size_t size)
 Acknowledges space claimed for putting data into a ring buffer.
 
ring_buf_size_t ring_buf_get_claim (struct ring_buf *buf, void **space, ring_buf_size_t size)
 Claims contiguous space for getting.
 
int ring_buf_get_ack (struct ring_buf *buf, ring_buf_size_t size)
 Acknowledges space claimed for getting data from a ring buffer.
 

Detailed Description

Functions for contiguous access to ring buffer data.

These functions allow for claiming and acknowledging contiguous space within the ring buffer for both putting and getting data.

Function Documentation

◆ ring_buf_get_ack()

int ring_buf_get_ack ( struct ring_buf buf,
ring_buf_size_t  size 
)

Acknowledges space claimed for getting data from a ring buffer.

Acknowledging a number of bytes advances the get zone.

Parameters
bufRing buffer address.
sizeNumber of bytes to acknowledge.
Return values
0on successful get.
-EINVALif size exceeds previously claimed aggregate space.

Definition at line 143 of file ring_buf.c.

◆ ring_buf_get_claim()

ring_buf_size_t ring_buf_get_claim ( struct ring_buf buf,
void **  space,
ring_buf_size_t  size 
)

Claims contiguous space for getting.

Advances the "get" head. One get operation starts with a claim. A successful claim expands the "get zone" by the requested number of bytes.

Note
The claim cannot span across the end of the buffer space. Buffer size less the get zone's head clamps the claim size. It cannot exceed the remaining contiguous space.
Parameters
bufRing buffer address.
spaceAddress of pointer to claimed space, or NULL to ignore.
sizeNumber of bytes to claim.
Returns
Number of bytes claimed.

Definition at line 127 of file ring_buf.c.

◆ ring_buf_put_ack()

int ring_buf_put_ack ( struct ring_buf buf,
ring_buf_size_t  size 
)

Acknowledges space claimed for putting data into a ring buffer.

Acknowledging a number of bytes advances the put zone. Notice that the claim cannot span across the end of the buffer space. Buffer size less the put zone's head clamps the claim size. It cannot exceed the remaining contiguous space.

Parameters
bufRing buffer address.
sizeNumber of bytes to acknowledge.
Return values
0on successful put.
-EINVALif size exceeds previously claimed aggregate space.

Definition at line 117 of file ring_buf.c.

◆ ring_buf_put_claim()

ring_buf_size_t ring_buf_put_claim ( struct ring_buf buf,
void **  space,
ring_buf_size_t  size 
)

Claims space for putting data into a ring buffer.

Claims contiguous space. Advances the "put" head. One put operation starts with a claim. A successful claim expands the "put zone" by the requested number of bytes.

Note
The claim cannot span across the end of the buffer space. Buffer size less the put zone's head clamps the claim size. It cannot exceed the remaining contiguous space.
Parameters
bufRing buffer address.
spaceAddress of pointer to claimed space, or NULL to ignore.
sizeNumber of bytes to claim.
Returns
Number of bytes claimed.

Definition at line 101 of file ring_buf.c.