Qt 4.8
Public Functions | Properties | List of all members
QFastMutex Class Reference

Public Functions

void lock ()
 
 QFastMutex ()
 
bool tryLock ()
 
void unlock ()
 

Properties

QAtomicInt contenders
 
QSemaphore semaphore
 

Detailed Description

Definition at line 58 of file qregion_qws.cpp.

Constructors and Destructors

◆ QFastMutex()

QFastMutex::QFastMutex ( )
inline

Definition at line 63 of file qregion_qws.cpp.

64  : contenders(0), semaphore(0)
65  { }
QAtomicInt contenders
Definition: qregion_qws.cpp:60
QSemaphore semaphore
Definition: qregion_qws.cpp:61

Functions

◆ lock()

void QFastMutex::lock ( )
inline

Definition at line 66 of file qregion_qws.cpp.

Referenced by qt_allocRegionMemory(), and qt_freeRegionMemory().

67  {
68  if (contenders.fetchAndAddAcquire(1) != 0) {
70  contenders.deref();
71  }
72  }
bool deref()
Atomically decrements the value of this QAtomicInt.
int fetchAndAddAcquire(int valueToAdd)
Atomic fetch-and-add.
void acquire(int n=1)
Tries to acquire n resources guarded by the semaphore.
Definition: qsemaphore.cpp:142
QAtomicInt contenders
Definition: qregion_qws.cpp:60
QSemaphore semaphore
Definition: qregion_qws.cpp:61

◆ tryLock()

bool QFastMutex::tryLock ( )
inline

Definition at line 73 of file qregion_qws.cpp.

74  {
75  return contenders.testAndSetAcquire(0, 1);
76  }
bool testAndSetAcquire(int expectedValue, int newValue)
Atomic test-and-set.
QAtomicInt contenders
Definition: qregion_qws.cpp:60

◆ unlock()

void QFastMutex::unlock ( )
inline

Definition at line 77 of file qregion_qws.cpp.

Referenced by qt_allocRegionMemory(), and qt_freeRegionMemory().

78  {
79  if (!contenders.testAndSetRelease(1, 0))
81  }
void release(int n=1)
Releases n resources guarded by the semaphore.
Definition: qsemaphore.cpp:161
bool testAndSetRelease(int expectedValue, int newValue)
Atomic test-and-set.
QAtomicInt contenders
Definition: qregion_qws.cpp:60
QSemaphore semaphore
Definition: qregion_qws.cpp:61

Properties

◆ contenders

QAtomicInt QFastMutex::contenders
private

Definition at line 60 of file qregion_qws.cpp.

◆ semaphore

QSemaphore QFastMutex::semaphore
private

Definition at line 61 of file qregion_qws.cpp.


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