Jamba C++ API  5.1.1
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. More...
 
void get (T &oElement)
 Returns the "current" value. More...
 
void get (T *oElement)
 Returns the "current" value. More...
 
void set (T const &iValue)
 Updates the current value with the provided one. More...
 
void set (T const *iValue)
 Updates the current value with the provided one. More...
 

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]

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

◆ AtomicValue() [2/2]

AtomicValue ( T const &  iValue)
inlineexplicit

Member Function Documentation

◆ get() [1/3]

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]

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]

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]

void set ( T const &  iValue)
inline

Updates the current value with the provided one.

◆ set() [2/2]

void set ( T const *  iValue)
inline

Updates the current value with the provided one.

Member Data Documentation

◆ fSpinLock

SpinLock fSpinLock
private

◆ fValue

std::unique_ptr<T> fValue
private

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