RTXI  2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
AtomicFifo Class Reference

Lockfree SINGLE producer / SINGLE consumer FIFO. More...

#include <atomic_fifo.h>

Public Member Functions

 AtomicFifo (size_t)
 ~AtomicFifo (void)
bool write (const void *buffer, size_t itemSize)
bool read (void *buffer, size_t itemSize)
bool isLockFree () const

Private Member Functions

size_t increment (size_t current_ptr, size_t itemSize) const

Private Attributes

char * data
std::atomic< size_t > head
std::atomic< size_t > tail
size_t fifoSize

Detailed Description

Lockfree SINGLE producer / SINGLE consumer FIFO.

Definition at line 33 of file atomic_fifo.h.

Constructor & Destructor Documentation

AtomicFifo::AtomicFifo(size_t s)

Definition at line 24 of file atomic_fifo.cpp.

AtomicFifo::~AtomicFifo(void )

Definition at line 30 of file atomic_fifo.cpp.

Member Function Documentation

size_t AtomicFifo::increment(size_t current_ptr,
size_t itemSize 

Definition at line 89 of file atomic_fifo.cpp.

bool AtomicFifo::isLockFree()const

Function to check if FIFO is truly atomic for the hardware architecture

Definition at line 94 of file atomic_fifo.cpp.

bool AtomicFifo::read(void * buffer,
size_t itemSize 

Function for reading data from atomic FIFO

bufferMemory source
itemSizeSize of memory chunk to be copied into fifo

Definition at line 61 of file atomic_fifo.cpp.

bool AtomicFifo::write(const void * buffer,
size_t itemSize 

Function for writing data to atomic FIFO

bufferMemory destination
itemSizeSize of memory chunk to be copied

Definition at line 35 of file atomic_fifo.cpp.

Member Data Documentation

char* AtomicFifo::data

Definition at line 65 of file atomic_fifo.h.

size_t AtomicFifo::fifoSize

Definition at line 68 of file atomic_fifo.h.

std::atomic<size_t> AtomicFifo::head

Definition at line 66 of file atomic_fifo.h.

std::atomic<size_t> AtomicFifo::tail

Definition at line 67 of file atomic_fifo.h.

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