RAUL  0.8.0
Public Member Functions | Protected Attributes | List of all members
Raul::RingBuffer Class Reference

A lock-free RingBuffer. More...

#include <RingBuffer.hpp>

Inheritance diagram for Raul::RingBuffer:
Inheritance graph

Public Member Functions

 RingBuffer (uint32_t size)
 
void reset ()
 Reset(empty) the ringbuffer. More...
 
uint32_t write_space () const
 
uint32_t read_space () const
 
uint32_t capacity () const
 
uint32_t peek (uint32_t size, void *dst)
 Peek at the ringbuffer (read w/o advancing read pointer). More...
 
bool full_peek (uint32_t size, void *dst)
 
uint32_t read (uint32_t size, void *dst)
 Read from the ringbuffer. More...
 
bool full_read (uint32_t size, void *dst)
 
bool skip (uint32_t size)
 
void write (uint32_t size, const void *src)
 

Protected Attributes

uint32_t _write_ptr
 
uint32_t _read_ptr
 
char *const _buf
 Contents.
 
const uint32_t _size
 Size (capacity) in bytes.
 

Detailed Description

A lock-free RingBuffer.

Read/Write realtime safe. Single-reader Single-writer thread safe.

Constructor & Destructor Documentation

◆ RingBuffer()

Raul::RingBuffer::RingBuffer ( uint32_t  size)
inlineexplicit
Parameters
sizeSize in bytes.

References _buf, and reset().

Member Function Documentation

◆ reset()

void Raul::RingBuffer::reset ( )
inline

Reset(empty) the ringbuffer.

NOT thread safe.

References _size, peek(), and read().

Referenced by RingBuffer().

◆ peek()

uint32_t Raul::RingBuffer::peek ( uint32_t  size,
void *  dst 
)
inline

Peek at the ringbuffer (read w/o advancing read pointer).

Note that a full read may not be done if the data wraps around. Caller must check return value and call again if necessary, or use the full_peek method which does this automatically.

References _buf, and _size.

Referenced by reset().

◆ read()

uint32_t Raul::RingBuffer::read ( uint32_t  size,
void *  dst 
)
inline

Read from the ringbuffer.

Note that a full read may not be done if the data wraps around. Caller must check return value and call again if necessary, or use the full_read method which does this automatically.

References _buf, and _size.

Referenced by reset().


The documentation for this class was generated from the following file: