Jamba C++ API 7.5.0
Loading...
Searching...
No Matches
AtomicValue< T > Class Template Reference

This is the lock free version of the AtomicValue. More...

#include <Concurrent.h>

Inherits SingleElementStorage< T >.

Public Member Functions

 AtomicValue (std::unique_ptr< T > iValue)
T const * get ()
void get (T &oElement)
 Copy the value to oElement.
void get (T *oElement)
 Copy the value to *oElement.
getCopy ()
void set (T const &iValue)
 Copy the value to make it accessible to get.
void set (T const *iValue)
 Copy the value to make it accessible to get.
template<class ElementModifier>
void update (ElementModifier const &iElementModifier)
 Use this flavor to avoid copy.
template<class ElementModifier>
bool updateIf (ElementModifier const &iElementModifier)
 Use this flavor to avoid copy.
Public Member Functions inherited from SingleElementStorage< T >
bool __isLockFree () const
 Used (from test) to make sure that it is a lock free implementation.
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 SingleElementStorage< T >
std::unique_ptr< Element__newElement () const
std::unique_ptr< T > __newT () const
std::unique_ptr< Elementload (std::unique_ptr< Element > iElement)
 Loads an element from storage.
std::unique_ptr< Elementstore (std::unique_ptr< Element > iElement)
 Stores an element in the storage.

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 Element = typename SingleElementStorage<T>::Element
private

Constructor & Destructor Documentation

◆ AtomicValue()

template<typename T>
AtomicValue ( std::unique_ptr< T > iValue)
inlineexplicit

Member Function Documentation

◆ get() [1/3]

template<typename T>
T const * get ( )
inline
Returns
the value

◆ get() [2/3]

template<typename T>
void get ( T & oElement)
inline

Copy the value to oElement.

◆ get() [3/3]

template<typename T>
void get ( T * oElement)
inline

Copy the value to *oElement.

◆ getCopy()

template<typename T>
T getCopy ( )
inline
Returns
a copy of the value

◆ set() [1/2]

template<typename T>
void set ( T const & iValue)
inline

Copy the value to make it accessible to get.

◆ set() [2/2]

template<typename T>
void set ( T const * iValue)
inline

Copy the value to make it accessible to get.

◆ update()

template<typename T>
template<class ElementModifier>
void 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 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> fGetValue
private

◆ fSetValue

template<typename T>
std::unique_ptr<Element> fSetValue
private

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