42 #ifndef QREADWRITELOCK_H 43 #define QREADWRITELOCK_H 45 #include <QtCore/qglobal.h> 68 bool tryLockForRead();
69 bool tryLockForRead(
int timeout);
72 bool tryLockForWrite();
73 bool tryLockForWrite(
int timeout);
84 #if defined(Q_CC_MSVC) 85 #pragma warning( push ) 86 #pragma warning( disable : 4312 ) // ignoring the warning from /Wp64 102 readWriteLock()->
unlock();
126 : q_val(reinterpret_cast<
quintptr>(areadWriteLock))
129 "QReadLocker",
"QReadWriteLock pointer is misaligned");
146 readWriteLock()->
unlock();
171 : q_val(reinterpret_cast<
quintptr>(areadWriteLock))
174 "QWriteLocker",
"QReadWriteLock pointer is misaligned");
178 #if defined(Q_CC_MSVC) 179 #pragma warning( pop ) 182 #else // QT_NO_THREAD 187 enum RecursionMode { NonRecursive, Recursive };
188 inline explicit QReadWriteLock(RecursionMode = NonRecursive) { }
189 inline ~QReadWriteLock() { }
191 static inline void lockForRead() { }
192 static inline bool tryLockForRead() {
return true; }
193 static inline bool tryLockForRead(
int timeout) {
Q_UNUSED(timeout);
return true; }
195 static inline void lockForWrite() { }
196 static inline bool tryLockForWrite() {
return true; }
197 static inline bool tryLockForWrite(
int timeout) {
Q_UNUSED(timeout);
return true; }
199 static inline void unlock() { }
208 inline QReadLocker(QReadWriteLock *) { }
209 inline ~QReadLocker() { }
211 static inline void unlock() { }
212 static inline void relock() { }
213 static inline QReadWriteLock *readWriteLock() {
return 0; }
222 inline explicit QWriteLocker(QReadWriteLock *) { }
223 inline ~QWriteLocker() { }
225 static inline void unlock() { }
226 static inline void relock() { }
227 static inline QReadWriteLock *readWriteLock() {
return 0; }
233 #endif // QT_NO_THREAD 239 #endif // QREADWRITELOCK_H
QIntegerForSizeof< void * >::Unsigned quintptr
#define QT_END_NAMESPACE
This macro expands to.
~QReadLocker()
Destroys the QReadLocker and unlocks the lock that was passed to the constructor. ...
void unlock()
Unlocks the lock.
RecursionMode
QReadWriteLock multiple times and the mutex won't be unlocked until a corresponding number of unlock(...
void relock()
Relocks an unlocked lock.
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
QReadWriteLock * readWriteLock() const
Returns a pointer to the read-write lock that was passed to the constructor.
void lockForWrite()
Locks the lock for writing.
void unlock()
Unlocks the lock associated with this locker.
~QWriteLocker()
Destroys the QWriteLocker and unlocks the lock that was passed to the constructor.
QReadWriteLock * readWriteLock() const
Returns a pointer to the read-write lock that was passed to the constructor.
#define QT_BEGIN_NAMESPACE
This macro expands to.
void lockForRead()
Locks the lock for reading.
The QReadLocker class is a convenience class that simplifies locking and unlocking read-write locks f...
The QWriteLocker class is a convenience class that simplifies locking and unlocking read-write locks ...
#define Q_ASSERT_X(cond, where, what)
The QReadWriteLock class provides read-write locking.
void unlock()
Unlocks the lock associated with this locker.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
void relock()
Relocks an unlocked lock.