HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SYS_AtomicInt< T > Class Template Reference

#include <SYS_AtomicInt.h>

Public Member Functions

 SYS_AtomicInt (T value=0)
 
 SYS_AtomicInt (SYS_EmptyConstructor)
 
T exchange (T val)
 
T exchangeAdd (T val)
 
T add (T val)
 Atomically adds val to myValue, returning the new value of myValue. More...
 
void maximum (T val)
 Atomically set myValue to the maximum of val and myValue. More...
 
T compare_swap (T expected, T desired)
 
void store (T val, SYS_MemoryOrder order=SYS_MEMORY_ORDER_SEQ_CST)
 
T load (SYS_MemoryOrder order=SYS_MEMORY_ORDER_SEQ_CST) const
 
 operator T () const
 Atomically retrieve value. Same as calling load(). More...
 
SYS_FORCE_INLINE T relaxedLoad () const
 
SYS_FORCE_INLINE void relaxedStore (T val)
 

Detailed Description

template<typename T>
class SYS_AtomicInt< T >

Definition at line 20 of file SYS_AtomicInt.h.

Constructor & Destructor Documentation

template<typename T>
SYS_AtomicInt< T >::SYS_AtomicInt ( T  value = 0)
inlineexplicit

Definition at line 23 of file SYS_AtomicInt.h.

template<typename T>
SYS_AtomicInt< T >::SYS_AtomicInt ( SYS_EmptyConstructor  )
inline

An empty constructor. This will initialize the value with garbage, unless used as a static object (in which case it will be guaranteed by the C++ standard to be initialized to zero). Only use if required to be set prior to other, dependent statically initialized objects.

Definition at line 29 of file SYS_AtomicInt.h.

Member Function Documentation

template<typename T>
SYS_ATOMIC_INLINE T SYS_AtomicInt< T >::add ( T  val)
inline

Atomically adds val to myValue, returning the new value of myValue.

Definition at line 105 of file SYS_AtomicInt.h.

template<typename T>
SYS_ATOMIC_INLINE T SYS_AtomicInt< T >::compare_swap ( T  expected,
T  desired 
)
inline

Atomically compares (myValue == expected), and if true, replaces myValue with desired. Returns prior myValue.

Definition at line 131 of file SYS_AtomicInt.h.

template<typename T>
SYS_ATOMIC_INLINE T SYS_AtomicInt< T >::exchange ( T  val)
inline

Atomically assigns val to myValue, returning the prior value of myValue.

Definition at line 91 of file SYS_AtomicInt.h.

template<typename T>
SYS_ATOMIC_INLINE T SYS_AtomicInt< T >::exchangeAdd ( T  val)
inline

Atomically adds val to myValue, returning the prior value of myValue.

Definition at line 98 of file SYS_AtomicInt.h.

template<typename T >
SYS_ATOMIC_INLINE T SYS_AtomicInt< T >::load ( SYS_MemoryOrder  order = SYS_MEMORY_ORDER_SEQ_CST) const
inline
Precondition
The supplied order must be one of [RELAXED, LOAD, SEQ_CST].

Definition at line 151 of file SYS_AtomicInt.h.

template<typename T>
SYS_ATOMIC_INLINE void SYS_AtomicInt< T >::maximum ( T  val)
inline

Atomically set myValue to the maximum of val and myValue.

Definition at line 112 of file SYS_AtomicInt.h.

template<typename T >
SYS_ATOMIC_INLINE SYS_AtomicInt< T >::operator T ( ) const

Atomically retrieve value. Same as calling load().

Definition at line 158 of file SYS_AtomicInt.h.

template<typename T>
SYS_FORCE_INLINE T SYS_AtomicInt< T >::relaxedLoad ( ) const
inline

Forced RELAXED memory load GCC has trouble inlining so we pull the definition up here.

Definition at line 61 of file SYS_AtomicInt.h.

template<typename T>
SYS_FORCE_INLINE void SYS_AtomicInt< T >::relaxedStore ( T  val)
inline

Definition at line 68 of file SYS_AtomicInt.h.

template<typename T>
SYS_ATOMIC_INLINE void SYS_AtomicInt< T >::store ( T  val,
SYS_MemoryOrder  order = SYS_MEMORY_ORDER_SEQ_CST 
)
inline
Precondition
The supplied order must be one of [RELAXED, STORE, SEQ_CST].

Next two methods intentionally not marked as volatile as this would cause &myValue to evaluate to a pointer to a volatile myValue and that has implications on MSVC2005+ beyond the C++ spec.

This shouldn't be a problem unless somebody needs a volatile instance of SYS_AtomicInt<T>.

Definition at line 144 of file SYS_AtomicInt.h.


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