Public Member Functions | Private Attributes | List of all members
QAtomicInt Class Reference

#include <qmutex_p.h>

Public Member Functions

 QAtomicInt (int v=0)
 
bool testAndSet (int expectedValue, int newValue)
 
int fetchAndAdd (int valueToAdd)
 
 operator int () const
 
bool operator== (int value) const
 
bool operator!= (int value) const
 
bool operator! () const
 

Private Attributes

volatile int m_value
 

Detailed Description

Definition at line 53 of file qmutex_p.h.

Constructor & Destructor Documentation

QAtomicInt::QAtomicInt ( int  v = 0)
inline

Definition at line 56 of file qmutex_p.h.

56 : m_value(v) {}
volatile int m_value
Definition: qmutex_p.h:65

Member Function Documentation

int QAtomicInt::fetchAndAdd ( int  valueToAdd)

Definition at line 108 of file qmutex_unix.cpp.

109 {
110  int returnValue;
111  pthread_mutex_lock(&qAtomicMutex);
112  returnValue = m_value;
113  m_value += valueToAdd;
114  pthread_mutex_unlock(&qAtomicMutex);
115  return returnValue;
116 }
volatile int m_value
Definition: qmutex_p.h:65
static pthread_mutex_t qAtomicMutex
Definition: qmutex_unix.cpp:49
QAtomicInt::operator int ( ) const
inline

Definition at line 59 of file qmutex_p.h.

59 { return m_value; }
volatile int m_value
Definition: qmutex_p.h:65
bool QAtomicInt::operator! ( ) const
inline

Definition at line 62 of file qmutex_p.h.

62 { return m_value == 0; }
volatile int m_value
Definition: qmutex_p.h:65
bool QAtomicInt::operator!= ( int  value) const
inline

Definition at line 61 of file qmutex_p.h.

61 { return m_value != value; }
volatile int m_value
Definition: qmutex_p.h:65
bool QAtomicInt::operator== ( int  value) const
inline

Definition at line 60 of file qmutex_p.h.

60 { return m_value == value; }
volatile int m_value
Definition: qmutex_p.h:65
bool QAtomicInt::testAndSet ( int  expectedValue,
int  newValue 
)

Definition at line 95 of file qmutex_unix.cpp.

96 {
97  bool returnValue = false;
98  pthread_mutex_lock(&qAtomicMutex);
99  if (m_value == expectedValue)
100  {
101  m_value = newValue;
102  returnValue = true;
103  }
104  pthread_mutex_unlock(&qAtomicMutex);
105  return returnValue;
106 }
volatile int m_value
Definition: qmutex_p.h:65
static pthread_mutex_t qAtomicMutex
Definition: qmutex_unix.cpp:49

Member Data Documentation

volatile int QAtomicInt::m_value
private

Definition at line 65 of file qmutex_p.h.


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