lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
Loading...
Searching...
No Matches
Pds::Fifo< T > Class Template Reference

Fixed-size ring buffer of T, not thread-safe. More...

#include <Fifo.hh>

Inherited by Pds::FifoW< Buffer >.

Public Member Functions

 Fifo (size_t size)
 Allocate size slots and start empty.
 
void clear ()
 Make the FIFO empty (the slots are not cleared).
 
bool push (const T &item)
 Copy item to the back; returns true, without storing, if the FIFO is full, else false.
 
bool pop (T &item)
 Move the front element into item; returns true, without changing item, if the FIFO is empty, else false.
 
T & front ()
 Return a reference to the front slot (not checked for emptiness).
 
const T & front () const
 Return a const reference to the front slot (not checked for emptiness).
 
const T & peek (size_t offset) const
 Return the slot offset positions after the front (wrapping; not checked against count()).
 
T & back ()
 Return a reference to the most recently pushed slot.
 
const T & back () const
 Return a const reference to the most recently pushed slot.
 
bool empty () const
 Return true if the FIFO holds no elements.
 
size_t size () const
 Return the capacity.
 
const size_t & count () const
 Return a reference to the number of elements held.
 

Detailed Description

template<class T>
class Pds::Fifo< T >

Fixed-size ring buffer of T, not thread-safe.

push() and pop() return true when they fail (full or empty).

Constructor & Destructor Documentation

◆ Fifo()

template<class T >
Pds::Fifo< T >::Fifo ( size_t  size)
inline

Allocate size slots and start empty.

Member Function Documentation

◆ back() [1/2]

template<class T >
T & Pds::Fifo< T >::back ( )
inline

Return a reference to the most recently pushed slot.

◆ back() [2/2]

template<class T >
const T & Pds::Fifo< T >::back ( ) const
inline

Return a const reference to the most recently pushed slot.

◆ clear()

template<class T >
void Pds::Fifo< T >::clear ( )
inline

Make the FIFO empty (the slots are not cleared).

◆ count()

template<class T >
const size_t & Pds::Fifo< T >::count ( ) const
inline

Return a reference to the number of elements held.

◆ empty()

template<class T >
bool Pds::Fifo< T >::empty ( ) const
inline

Return true if the FIFO holds no elements.

◆ front() [1/2]

template<class T >
T & Pds::Fifo< T >::front ( )
inline

Return a reference to the front slot (not checked for emptiness).

◆ front() [2/2]

template<class T >
const T & Pds::Fifo< T >::front ( ) const
inline

Return a const reference to the front slot (not checked for emptiness).

◆ peek()

template<class T >
const T & Pds::Fifo< T >::peek ( size_t  offset) const
inline

Return the slot offset positions after the front (wrapping; not checked against count()).

◆ pop()

template<class T >
bool Pds::Fifo< T >::pop ( T &  item)
inline

Move the front element into item; returns true, without changing item, if the FIFO is empty, else false.

◆ push()

template<class T >
bool Pds::Fifo< T >::push ( const T &  item)
inline

Copy item to the back; returns true, without storing, if the FIFO is full, else false.

◆ size()

template<class T >
size_t Pds::Fifo< T >::size ( ) const
inline

Return the capacity.


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