RAUL 0.7.0
Public Member Functions | Protected Attributes

Raul::RingBuffer< T > Class Template Reference

A lock-free RingBuffer. More...

#include <RingBuffer.hpp>

List of all members.

Public Member Functions

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

Protected Attributes

int _write_ptr
int _read_ptr
size_t _size
 Size (capacity) in bytes.
char * _buf
 Contents.

Detailed Description

template<typename T>
class Raul::RingBuffer< T >

A lock-free RingBuffer.

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


Constructor & Destructor Documentation

template<typename T>
Raul::RingBuffer< T >::RingBuffer ( size_t  size) [inline]
Parameters:
sizeSize in bytes.

Member Function Documentation

template<typename T>
void Raul::RingBuffer< T >::reset ( ) [inline]

Reset(empty) the ringbuffer.

NOT thread safe.

Referenced by Raul::RingBuffer< uint8_t >::RingBuffer().

template<typename T>
size_t Raul::RingBuffer< T >::peek ( size_t  size,
T *  dst 
)

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.

template<typename T>
size_t Raul::RingBuffer< T >::read ( size_t  size,
T *  dst 
)

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.


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