19 enum RecursionMode { NonRecursive, Recursive };
21 QT_CORE_INLINE_SINCE(6, 6)
23 QT_CORE_INLINE_SINCE(6, 6)
26 QT_CORE_INLINE_SINCE(6, 6)
28#if QT_CORE_REMOVED_SINCE(6, 6)
29 bool tryLockForRead();
31 QT_CORE_INLINE_SINCE(6, 6)
32 bool tryLockForRead(
int timeout);
35 QT_CORE_INLINE_SINCE(6, 6)
37#if QT_CORE_REMOVED_SINCE(6, 6)
38 bool tryLockForWrite();
40 QT_CORE_INLINE_SINCE(6, 6)
41 bool tryLockForWrite(
int timeout);
48 QAtomicPointer<QReadWriteLockPrivate> d_ptr;
54#if QT_CORE_INLINE_IMPL_SINCE(6, 6)
55QReadWriteLock::QReadWriteLock(RecursionMode recursionMode)
56 : d_ptr(recursionMode == Recursive ? initRecursive() :
nullptr)
60QReadWriteLock::~QReadWriteLock()
62 if (
auto d = d_ptr.loadAcquire())
66void QReadWriteLock::lockForRead()
71bool QReadWriteLock::tryLockForRead(
int timeout)
76void QReadWriteLock::lockForWrite()
81bool QReadWriteLock::tryLockForWrite(
int timeout)
88#pragma warning( push )
89#pragma warning( disable : 4312 )
106 readWriteLock()->unlock();
115 readWriteLock()->lockForRead();
130 : q_val(reinterpret_cast<
quintptr>(areadWriteLock))
133 "QReadLocker",
"QReadWriteLock pointer is misaligned");
151 readWriteLock()->unlock();
160 readWriteLock()->lockForWrite();
176 : q_val(reinterpret_cast<
quintptr>(areadWriteLock))
179 "QWriteLocker",
"QReadWriteLock pointer is misaligned");
183#if defined(Q_CC_MSVC)
184#pragma warning( pop )
192 enum RecursionMode { NonRecursive, Recursive };
193 inline explicit QReadWriteLock(RecursionMode = NonRecursive)
noexcept { }
196 void lockForRead() noexcept { }
197 bool tryLockForRead() noexcept {
return true; }
201 void lockForWrite() noexcept { }
202 bool tryLockForWrite() noexcept {
return true; }
206 void unlock() noexcept { }