QMutexLocker Class Reference

QMutexLocker Class Reference

#include <qmutex.h>

Class Description

Definition at line 101 of file qmutex.h.

Public Member Functions

 QMutexLocker (QMutex *m)
 
 ~QMutexLocker ()
 
void unlock ()
 
void relock ()
 
QMutexmutex () const
 

Constructor & Destructor Documentation

QMutexLocker ( QMutex m)
inlineexplicit

Definition at line 104 of file qmutex.h.

105  {
106  Q_ASSERT_X((reinterpret_cast<quintptr>(m) & quintptr(1u)) == quintptr(0),
107  "QMutexLocker", "QMutex pointer is misaligned");
108  if (m) {
109  m->lockInline();
110  val = reinterpret_cast<quintptr>(m) | quintptr(1u);
111  } else {
112  val = 0;
113  }
114  }
void lockInline()
Definition: qmutex.h:198
~QMutexLocker ( )
inline

Definition at line 115 of file qmutex.h.

115 { unlock(); }
void unlock()
Definition: qmutex.h:117

Member Function Documentation

void unlock ( )
inline

Definition at line 117 of file qmutex.h.

118  {
119  if ((val & quintptr(1u)) == quintptr(1u)) {
120  val &= ~quintptr(1u);
121  mutex()->unlockInline();
122  }
123  }
void unlockInline()
Definition: qmutex.h:196
QMutex * mutex() const
Definition: qmutex.h:140
void relock ( )
inline

Definition at line 125 of file qmutex.h.

126  {
127  if (val) {
128  if ((val & quintptr(1u)) == quintptr(0u)) {
129  mutex()->lockInline();
130  val |= quintptr(1u);
131  }
132  }
133  }
void lockInline()
Definition: qmutex.h:198
QMutex * mutex() const
Definition: qmutex.h:140
QMutex* mutex ( ) const
inline

Definition at line 140 of file qmutex.h.

141  {
142  return reinterpret_cast<QMutex *>(val & ~quintptr(1u));
143  }
Definition: qmutex.h:60

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