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

#include <Concurrent.h>

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

Public Member Functions

 AtomicValue (std::unique_ptr< T > iValue)
 
T const * get ()
 
void get (T &oElement)
 
void get (T *oElement)
 
getCopy ()
 
void set (T const &iValue)
 
void set (T const *iValue)
 
template<class ElementModifier >
void update (ElementModifier const &iElementModifier)
 
template<class ElementModifier >
bool updateIf (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 Attributes

std::unique_ptr< ElementfGetValue
 
std::unique_ptr< ElementfSetValue
 

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::AtomicValue< T >

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

Member Typedef Documentation

◆ Element

template<typename T>
using pongasoft::Utils::Concurrent::LockFree::AtomicValue< T >::Element = typename SingleElementStorage<T>::Element
private

Constructor & Destructor Documentation

◆ AtomicValue()

template<typename T>
pongasoft::Utils::Concurrent::LockFree::AtomicValue< T >::AtomicValue ( std::unique_ptr< T >  iValue)
inlineexplicit

Member Function Documentation

◆ get() [1/3]

template<typename T>
T const* pongasoft::Utils::Concurrent::LockFree::AtomicValue< T >::get ( )
inline
Returns
the value

◆ get() [2/3]

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

Copy the value to oElement

◆ get() [3/3]

template<typename T>
void pongasoft::Utils::Concurrent::LockFree::AtomicValue< T >::get ( T *  oElement)
inline

Copy the value to *oElement

◆ getCopy()

template<typename T>
T pongasoft::Utils::Concurrent::LockFree::AtomicValue< T >::getCopy ( )
inline
Returns
a copy of the value

◆ set() [1/2]

template<typename T>
void pongasoft::Utils::Concurrent::LockFree::AtomicValue< T >::set ( T const &  iValue)
inline

Copy the value to make it accessible to get

◆ set() [2/2]

template<typename T>
void pongasoft::Utils::Concurrent::LockFree::AtomicValue< T >::set ( T const *  iValue)
inline

Copy the value to make it accessible to get

◆ update()

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

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

◆ updateIf()

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

Use this flavor 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 update should happen and false otherwise.

Member Data Documentation

◆ fGetValue

template<typename T>
std::unique_ptr<Element> pongasoft::Utils::Concurrent::LockFree::AtomicValue< T >::fGetValue
private

◆ fSetValue

template<typename T>
std::unique_ptr<Element> pongasoft::Utils::Concurrent::LockFree::AtomicValue< T >::fSetValue
private

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