mpacklog — Log dictionaries to file using MessagePack  v2.1.0
mpacklog::CircularBuffer< T, Size > Struct Template Reference

#include <CircularBuffer.h>

Public Types

enum  { Capacity = Size + 1 }
 

Public Member Functions

 CircularBuffer ()
 Initialize buffer. More...
 
bool push (const T &item)
 Push data to the buffer. More...
 
bool pop (T &item)
 Pop next item from the buffer. More...
 
bool empty ()
 Check whether the buffer is empty. More...
 
size_t size ()
 Number of items in the buffer. More...
 

Detailed Description

template<typename T, size_t Size>
struct mpacklog::CircularBuffer< T, Size >

Lock-free, thread-safe, single-producer single-consumer circular buffer.

Loosely based off the article: https://www.codeproject.com/Articles/43510/Lock-Free-Single-Producer-Single-Consumer-Circular

Definition at line 38 of file CircularBuffer.h.

Member Enumeration Documentation

◆ anonymous enum

template<typename T , size_t Size>
anonymous enum
Enumerator
Capacity 

Definition at line 40 of file CircularBuffer.h.

Constructor & Destructor Documentation

◆ CircularBuffer()

template<typename T , size_t Size>
mpacklog::CircularBuffer< T, Size >::CircularBuffer ( )
inline

Initialize buffer.

Definition at line 43 of file CircularBuffer.h.

Member Function Documentation

◆ empty()

template<typename T , size_t Size>
bool mpacklog::CircularBuffer< T, Size >::empty ( )
inline

Check whether the buffer is empty.

Definition at line 85 of file CircularBuffer.h.

◆ pop()

template<typename T , size_t Size>
bool mpacklog::CircularBuffer< T, Size >::pop ( T &  item)
inline

Pop next item from the buffer.

Parameters
[out]itemPopped item will be written there.
Returns
True if an item was popped, false if the buffer is empty.

Definition at line 74 of file CircularBuffer.h.

◆ push()

template<typename T , size_t Size>
bool mpacklog::CircularBuffer< T, Size >::push ( const T &  item)
inline

Push data to the buffer.

Parameters
[in]itemNew item to push.
Returns
True if the item was pushed, false if the buffer is full.

Definition at line 57 of file CircularBuffer.h.

◆ size()

template<typename T , size_t Size>
size_t mpacklog::CircularBuffer< T, Size >::size ( )
inline

Number of items in the buffer.

Definition at line 88 of file CircularBuffer.h.


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