PTLib  Version 2.18.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
atomic.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  atomic< Type >
 
struct  PAtomicEnum< Enum >
 
class  PAtomicInteger
 
class  PAtomicBoolean
 

Macros

#define P_DEFINE_ATOMIC_FUNCTIONS(Type, Exch, FetchAdd, AddFetch, CompExch)
 
#define P_DEFINE_ATOMIC_INT_CLASS(Type, Exch, FetchAdd, AddFetch, CompExch)
 
#define P_DEFINE_ATOMIC_PTR_CLASS(Exch, FetchAdd, AddFetch, CompExch)
 

Macro Definition Documentation

#define P_DEFINE_ATOMIC_FUNCTIONS (   Type,
  Exch,
  FetchAdd,
  AddFetch,
  CompExch 
)
Value:
__inline atomic() : m_storage() { } \
__inline atomic(Type value) : m_storage(value) { } \
__inline atomic(const atomic & other) : m_storage((Type)AddFetch(const_cast<Type *>(&other.m_storage), 0)) { } \
__inline atomic & operator=(const atomic & other) { store(other.load()); return *this; } \
__inline atomic & operator=(Type other) { store(other); return *this; } \
__inline operator Type() const { return (Type)AddFetch(const_cast<Type *>(&m_storage), 0); } \
__inline bool compare_exchange_strong(Type & comp, Type value) { return CompExch(&m_storage, comp, value); } \
__inline void store(Type value) { exchange(value); } \
__inline Type load() const { return (Type)AddFetch(const_cast<Type *>(&m_storage), 0); } \
__inline Type exchange(Type value) { return (Type)Exch(&m_storage, value); } \
__inline Type operator++() { return (Type)AddFetch(&m_storage, 1); } \
__inline Type operator++(int) { return (Type)FetchAdd(&m_storage, 1); } \
__inline Type operator+=(Type i) { return (Type)AddFetch(&m_storage, i); } \
__inline Type operator--() { return (Type)AddFetch(&m_storage, -1); } \
__inline Type operator--(int) { return (Type)FetchAdd(&m_storage, -1); } \
__inline Type operator-=(Type i) { return (Type)AddFetch(&m_storage, -i); } \
__inline Type load() const
Definition: atomic.h:51
Definition: atomic.h:43
#define P_DEFINE_ATOMIC_INT_CLASS (   Type,
  Exch,
  FetchAdd,
  AddFetch,
  CompExch 
)
Value:
template <> struct atomic<Type> { \
P_DEFINE_ATOMIC_FUNCTIONS(Type,Exch,FetchAdd,AddFetch,CompExch) \
private: volatile Type m_storage; \
}
#define P_DEFINE_ATOMIC_FUNCTIONS(Type, Exch, FetchAdd, AddFetch, CompExch)
Definition: atomic.h:88
Definition: atomic.h:43
#define P_DEFINE_ATOMIC_PTR_CLASS (   Exch,
  FetchAdd,
  AddFetch,
  CompExch 
)
Value:
template <typename Type> struct atomic<Type *> { \
P_DEFINE_ATOMIC_FUNCTIONS(Type*,Exch,FetchAdd,AddFetch,CompExch) \
private: volatile Type * m_storage; \
}
#define P_DEFINE_ATOMIC_FUNCTIONS(Type, Exch, FetchAdd, AddFetch, CompExch)
Definition: atomic.h:88
Definition: atomic.h:43