QTrk
Public Member Functions | Private Attributes | List of all members
Atomic< T > Class Template Reference

#include <threads.h>

Public Member Functions

 Atomic (const T &o=T())
 
 operator T () const
 
Atomicoperator= (const T &x)
 
void set (const T &x)
 
get () const
 

Private Attributes

Threads::Mutex m
 
data
 

Detailed Description

template<typename T>
class Atomic< T >

Definition at line 156 of file threads.h.

Constructor & Destructor Documentation

§ Atomic()

template<typename T>
Atomic< T >::Atomic ( const T &  o = T())
inline

Definition at line 160 of file threads.h.

160 : data(o) {} // no need for locking: the object is not allowed to be used before the constructor is done anyway
T data
Definition: threads.h:158

Member Function Documentation

§ get()

template<typename T>
T Atomic< T >::get ( ) const
inline

Definition at line 168 of file threads.h.

168  {
169  m.lock();
170  T x=data;
171  m.unlock();
172  return x;
173  }
void lock()
Definition: threads.h:74
T data
Definition: threads.h:158
void unlock()
Definition: threads.h:79
Threads::Mutex m
Definition: threads.h:157

§ operator T()

template<typename T>
Atomic< T >::operator T ( ) const
inline

Definition at line 161 of file threads.h.

161 { return get(); };

§ operator=()

template<typename T>
Atomic& Atomic< T >::operator= ( const T &  x)
inline

Definition at line 162 of file threads.h.

162 { set(x); return *this; }

§ set()

template<typename T>
void Atomic< T >::set ( const T &  x)
inline

Definition at line 163 of file threads.h.

163  {
164  m.lock();
165  data=x;
166  m.unlock();
167  }
void lock()
Definition: threads.h:74
T data
Definition: threads.h:158
void unlock()
Definition: threads.h:79
Threads::Mutex m
Definition: threads.h:157

Member Data Documentation

§ data

template<typename T>
T Atomic< T >::data
private

Definition at line 158 of file threads.h.

§ m

template<typename T>
Threads::Mutex Atomic< T >::m
mutableprivate

Definition at line 157 of file threads.h.


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