stdex Additional custom or not Standard C++ covered algorithms

Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
stdex::ring< T, N_cap > 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 [N_cap]

## Detailed Description

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

Ring buffer.

Template Parameters

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

## Member Function Documentation

## ◆ back()

template<class T , size_t N_cap>

std::tuple< T *, size_t > stdex::ring< T, N_cap >::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 N_cap>

std::tuple< T *, size_t > stdex::ring< T, N_cap >::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 N_cap>

void stdex::ring< T, N_cap >::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 N_cap>

void stdex::ring< T, N_cap >::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