Loading...
Searching...
No Matches
stdex::ring< T, CAPACITY > Class Template Reference

Ring buffer. More...

`#include <stdex/ring.hpp>`

## Public Member Functions

std::tuple< T *, size_t > | back ()
| Allocates the data after the ring tail. Use push() after the allocated data is populated.
void | push (size_t size)
| Notifies the receiver the data was populated.
std::tuple< T *, size_t > | front ()
| Peeks the data at the ring head. Use pop() after the data was consumed.
void | pop (size_t size)
| Notifies the sender the data was consumed.
void | quit ()
| Cancells waiting sender and receiver.
void | sync ()
| Waits until the ring is flush.

## Protected Member Functions

size_t | wrap (size_t idx) const
size_t | space () const
bool | empty () const

## Protected Attributes

std::mutex | m_mutex
std::condition_variable | m_head_moved
std::condition_variable | m_tail_moved
size_t | m_head
size_t | m_size
bool | m_quit
T | m_data [CAPACITY]

## Detailed Description

template<class T, size_t CAPACITY>
class stdex::ring< T, CAPACITY >

Ring buffer.

Template Parameters

  T | Ring element type
  CAPACITY | Ring capacity (in number of elements)

## Member Function Documentation

## back()

template<class T , size_t CAPACITY>

std::tuple< T *, size_t > stdex::ring< T, CAPACITY >::back | ( |  | ) |

inline

Allocates the data after the ring tail. Use push() after the allocated data is populated.

Returns
  Pointer to data available for writing and maximum data size to write. Or, `{nullptr, 0}` if quit() has been called.

## front()

template<class T , size_t CAPACITY>

std::tuple< T *, size_t > stdex::ring< T, CAPACITY >::front | ( |  | ) |

inline

Peeks the data at the ring head. Use pop() after the data was consumed.

Returns
  Pointer to data available for reading and maximum data size to read. Or, `{nullptr, 0}` if quit() has been called.

## pop()

template<class T , size_t CAPACITY>

void stdex::ring< T, CAPACITY >::pop | ( | size_t | size | ) |

inline

Notifies the sender the data was consumed.

Parameters

  [in] | size | Amount of data that was really consumed

## push()

template<class T , size_t CAPACITY>

void stdex::ring< T, CAPACITY >::push | ( | size_t | size | ) |

inline

Notifies the receiver the data was populated.

Parameters

  [in] | size | Amount of data that was really populated

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

- include/stdex/ring.hpp