QReadWriteLock: use NSDMI to simplify the Private ctor

Change-Id: I7267dedb152186ad8c74cbf2eddd863c3bc0845f
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Marc Mutz 2019-09-09 16:37:11 +02:00
parent e8bca8e763
commit 0f219d2054

View File

@ -63,17 +63,16 @@ QT_BEGIN_NAMESPACE
class QReadWriteLockPrivate class QReadWriteLockPrivate
{ {
public: public:
QReadWriteLockPrivate(bool isRecursive = false) explicit QReadWriteLockPrivate(bool isRecursive = false)
: readerCount(0), writerCount(0), waitingReaders(0), waitingWriters(0), : recursive(isRecursive) {}
recursive(isRecursive), id(0), currentWriter(nullptr) {}
QMutex mutex; QMutex mutex;
QWaitCondition writerCond; QWaitCondition writerCond;
QWaitCondition readerCond; QWaitCondition readerCond;
int readerCount; int readerCount = 0;
int writerCount; int writerCount = 0;
int waitingReaders; int waitingReaders = 0;
int waitingWriters; int waitingWriters = 0;
const bool recursive; const bool recursive;
//Called with the mutex locked //Called with the mutex locked
@ -82,19 +81,18 @@ public:
void unlock(); void unlock();
//memory management //memory management
int id; int id = 0;
void release(); void release();
static QReadWriteLockPrivate *allocate(); static QReadWriteLockPrivate *allocate();
// Recusive mutex handling // Recusive mutex handling
Qt::HANDLE currentWriter; Qt::HANDLE currentWriter = {};
QHash<Qt::HANDLE, int> currentReaders; QHash<Qt::HANDLE, int> currentReaders;
// called with the mutex unlocked // called with the mutex unlocked
bool recursiveLockForWrite(int timeout); bool recursiveLockForWrite(int timeout);
bool recursiveLockForRead(int timeout); bool recursiveLockForRead(int timeout);
void recursiveUnlock(); void recursiveUnlock();
}; };
QT_END_NAMESPACE QT_END_NAMESPACE