HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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...
 
void minimum (T val)
 Atomically set myValue to the minimum 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
 
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 19 of file SYS_AtomicInt.h.

Constructor & Destructor Documentation

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

Definition at line 22 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 28 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 107 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 152 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 93 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 100 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 172 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 114 of file SYS_AtomicInt.h.

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

Atomically set myValue to the minimum of val and myValue.

Definition at line 133 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 59 of file SYS_AtomicInt.h.

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

Definition at line 66 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 165 of file SYS_AtomicInt.h.


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