Jamba  3.0.2
pongasoft::Utils::Concurrent::LockFree::SingleElementQueue< T > Class Template Reference

#include <Concurrent.h>

Inherits pongasoft::Utils::Concurrent::LockFree::SingleElementStorage< T >.

Public Member Functions

T const * last () const
 
void last (T &oElement) const
 
T * pop ()
 
bool pop (T &oElement)
 
T const * popOrLast ()
 
void popOrLast (T &oElement)
 
void push (T const &iElement)
 
void push (T const *iElement)
 
 SingleElementQueue ()
 
 SingleElementQueue (std::unique_ptr< T > iElement, bool iIsEmpty=false)
 
template<class ElementModifier >
void updateAndPush (ElementModifier const &iElementModifier)
 
template<class ElementModifier >
bool updateAndPushIf (ElementModifier const &iElementModifier)
 
- Public Member Functions inherited from pongasoft::Utils::Concurrent::LockFree::SingleElementStorage< T >
bool __isLockFree () const
 
bool isEmpty () const
 
 SingleElementStorage (std::unique_ptr< T > iElement, bool iIsEmpty) noexcept
 
 ~SingleElementStorage ()
 

Private Types

using Element = typename SingleElementStorage< T >::Element
 

Private Member Functions

void pushValue ()
 

Private Attributes

std::unique_ptr< ElementfPopValue
 
std::unique_ptr< ElementfPushValue
 

Additional Inherited Members

- Protected Member Functions inherited from pongasoft::Utils::Concurrent::LockFree::SingleElementStorage< T >
std::unique_ptr< Element__newElement () const
 
std::unique_ptr< T > __newT () const
 
std::unique_ptr< Elementload (std::unique_ptr< Element > iElement)
 
std::unique_ptr< Elementstore (std::unique_ptr< Element > iElement)
 

Detailed Description

template<typename T>
class pongasoft::Utils::Concurrent::LockFree::SingleElementQueue< T >

This is the lock free version of the SingleElementQueue. Internally it uses a different pointer for push and pop. As described in the comment for SingleElementStorage, all methods related to 'pop' can be called in one thread while all methods related to 'push' can be called by another.

Member Typedef Documentation

◆ Element

Constructor & Destructor Documentation

◆ SingleElementQueue() [1/2]

◆ SingleElementQueue() [2/2]

template<typename T>
pongasoft::Utils::Concurrent::LockFree::SingleElementQueue< T >::SingleElementQueue ( std::unique_ptr< T >  iElement,
bool  iIsEmpty = false 
)
inlineexplicit

This constructor should be used if T does not provide an empty constructor

Member Function Documentation

◆ last() [1/2]

template<typename T>
T const* pongasoft::Utils::Concurrent::LockFree::SingleElementQueue< T >::last ( ) const
inline
Returns
returns the last value that was popped (never nullptr). Does NOT check for new value

◆ last() [2/2]

template<typename T>
void pongasoft::Utils::Concurrent::LockFree::SingleElementQueue< T >::last ( T &  oElement) const
inline

Copy the last value that was popped to oElement. Does NOT check for new value

◆ pop() [1/2]

template<typename T>
T* pongasoft::Utils::Concurrent::LockFree::SingleElementQueue< T >::pop ( )
inline
Returns
the value popped or nullptr if nothing to pop

◆ pop() [2/2]

template<typename T>
bool pongasoft::Utils::Concurrent::LockFree::SingleElementQueue< T >::pop ( T &  oElement)
inline

Copy the popped value to oElement and return true when there is a new value otherwise do nothing and return false.

◆ popOrLast() [1/2]

template<typename T>
T const* pongasoft::Utils::Concurrent::LockFree::SingleElementQueue< T >::popOrLast ( )
inline
Returns
if there is a new value to pop, returns it otherwise return the last value that was popped (never nullptr)

◆ popOrLast() [2/2]

template<typename T>
void pongasoft::Utils::Concurrent::LockFree::SingleElementQueue< T >::popOrLast ( T &  oElement)
inline

Copy either the new value (if there is one) or the last value that was popped to oElement

◆ push() [1/2]

template<typename T>
void pongasoft::Utils::Concurrent::LockFree::SingleElementQueue< T >::push ( T const &  iElement)
inline

Pushes (a copy of) iElement in the queue.

◆ push() [2/2]

template<typename T>
void pongasoft::Utils::Concurrent::LockFree::SingleElementQueue< T >::push ( T const *  iElement)
inline

Pushes (a copy of) *iElement in the queue.

◆ pushValue()

template<typename T>
void pongasoft::Utils::Concurrent::LockFree::SingleElementQueue< T >::pushValue ( )
inlineprivate

◆ updateAndPush()

template<typename T>
template<class ElementModifier >
void pongasoft::Utils::Concurrent::LockFree::SingleElementQueue< T >::updateAndPush ( ElementModifier const &  iElementModifier)
inline

Use this flavor of push to avoid copy. ElementModifier will be called back with the internal pointer to update it.

◆ updateAndPushIf()

template<typename T>
template<class ElementModifier >
bool pongasoft::Utils::Concurrent::LockFree::SingleElementQueue< T >::updateAndPushIf ( ElementModifier const &  iElementModifier)
inline

Use this flavor of push to avoid copy. ElementModifier will be called back with the internal pointer to update it. This flavor uses a callback that returns true when the push should happen and false otherwise.

Member Data Documentation

◆ fPopValue

template<typename T>
std::unique_ptr<Element> pongasoft::Utils::Concurrent::LockFree::SingleElementQueue< T >::fPopValue
private

◆ fPushValue

template<typename T>
std::unique_ptr<Element> pongasoft::Utils::Concurrent::LockFree::SingleElementQueue< T >::fPushValue
private

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