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

This class encapsulates a single atomic value. More...

#include <Concurrent.h>

Public Member Functions

 AtomicValue (std::unique_ptr< T > iValue)
 AtomicValue (T const &iValue)
get ()
 Returns the "current" value.
void get (T &oElement)
 Returns the "current" value.
void get (T *oElement)
 Returns the "current" value.
void set (T const &iValue)
 Updates the current value with the provided one.
void set (T const *iValue)
 Updates the current value with the provided one.

Private Attributes

SpinLock fSpinLock
std::unique_ptr< T > fValue

Detailed Description

template<typename T>
class pongasoft::Utils::Concurrent::WithSpinLock::AtomicValue< T >

This class encapsulates a single atomic value.

This implementation uses a SpinLock and is thread safe to be called by any number of threads. This implementation does not allocate any memory and is expecting the T type to have an empty constructor, copy constructor and operator=.

Constructor & Destructor Documentation

◆ AtomicValue() [1/2]

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

◆ AtomicValue() [2/2]

template<typename T>
AtomicValue ( T const & iValue)
inlineexplicit

Member Function Documentation

◆ get() [1/3]

template<typename T>
T get ( )
inline

Returns the "current" value.

Note that this method should be called by one thread at a time (it is ok to call "set" at the same time with another thread). The return value is copied in the oElement (copy vs creation).

◆ get() [2/3]

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

Returns the "current" value.

Note that this method should be called by one thread at a time (it is ok to call "set" at the same time with another thread). The return value is copied in the oElement (copy vs creation).

◆ get() [3/3]

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

Returns the "current" value.

Note that this method should be called by one thread at a time (it is ok to call "set" at the same time with another thread). The return value is copied in the oElement (copy vs creation).

◆ set() [1/2]

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

Updates the current value with the provided one.

◆ set() [2/2]

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

Updates the current value with the provided one.

Member Data Documentation

◆ fSpinLock

template<typename T>
SpinLock fSpinLock
private

◆ fValue

template<typename T>
std::unique_ptr<T> fValue
private

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