45 #include <QtCore/qglobal.h> 46 #include <QtCore/qatomic.h> 72 inline void lockInline();
74 bool tryLock(
int timeout);
75 inline bool tryLockInline();
77 inline void unlockInline();
79 #if defined(QT3_SUPPORT) 80 inline QT3_SUPPORT
bool locked()
87 inline QT3_SUPPORT_CONSTRUCTOR
QMutex(
bool recursive)
89 new (
this)
QMutex(recursive ? Recursive : NonRecursive);
95 void unlockInternal();
107 "QMutexLocker",
"QMutex pointer is misaligned");
121 mutex()->unlockInline();
129 mutex()->lockInline();
135 #if defined(Q_CC_MSVC) 136 #pragma warning( push ) 137 #pragma warning( disable : 4312 ) // ignoring the warning from /Wp64 145 #if defined(Q_CC_MSVC) 146 #pragma warning( pop ) 171 }
else if (!
d->contenders.testAndSetRelease(1, 0)) {
181 return d->contenders.testAndSetAcquire(0, 1);
189 }
else if(!tryLockInline()) {
199 #endif // QT_NO_DEBUG 202 #else // QT_NO_THREAD 213 static inline void lock() {}
214 static inline void lockInline() {}
215 static inline bool tryLock(
int timeout = 0) {
Q_UNUSED(timeout);
return true; }
216 static inline bool tryLockInline() {
return true; }
217 static inline void unlock() {}
218 static inline void unlockInline() {}
220 #if defined(QT3_SUPPORT) 221 static inline QT3_SUPPORT
bool locked() {
return false; }
231 inline explicit QMutexLocker(QMutex *) {}
232 inline ~QMutexLocker() {}
234 static inline void unlock() {}
235 static void relock() {}
236 static inline QMutex *mutex() {
return 0; }
242 #endif // QT_NO_THREAD
QMutexLocker(QMutex *m)
Constructs a QMutexLocker and locks mutex.
QIntegerForSizeof< void * >::Unsigned quintptr
#define QT_END_NAMESPACE
This macro expands to.
The QMutex class provides access serialization between threads.
The QAtomicInt class provides platform-independent atomic operations on integers. ...
void unlock()
Unlocks this mutex locker.
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
void relock()
Relocks an unlocked mutex locker.
#define QT_BEGIN_NAMESPACE
This macro expands to.
~QMutexLocker()
Destroys the QMutexLocker and unlocks the mutex that was locked in the constructor.
#define Q_ASSERT_X(cond, where, what)
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
static QReadWriteLock lock
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
QMutex * mutex() const
Returns a pointer to the mutex that was locked in the constructor.