diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2016-03-22 07:24:57 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2016-03-22 07:28:42 +0100 |
commit | a02863234d76abb6c9f289026ae4ea3145924f30 (patch) | |
tree | aef6381d0000a78ba69ac80eb03739b1c8ca5fc3 /src/corelib/thread/qreadwritelock_p.h | |
parent | e77b13621f0057374d83a2b884f03dd2e5b7b88c (diff) | |
parent | e4d79e1fdeb6b26ba0b12b578daacf7cd672b960 (diff) |
Merge remote-tracking branch 'origin/5.7' into dev
Conflicts:
configure
mkspecs/common/wince/qplatformdefs.h
src/plugins/platforms/directfb/qdirectfbbackingstore.cpp
src/plugins/platforms/xcb/qxcbbackingstore.cpp
Change-Id: Ied4d31264a9afca9514b51a7eb1494c28712793c
Diffstat (limited to 'src/corelib/thread/qreadwritelock_p.h')
-rw-r--r-- | src/corelib/thread/qreadwritelock_p.h | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/src/corelib/thread/qreadwritelock_p.h b/src/corelib/thread/qreadwritelock_p.h index 1f6f73c8e3..285f017655 100644 --- a/src/corelib/thread/qreadwritelock_p.h +++ b/src/corelib/thread/qreadwritelock_p.h @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2016 Olivier Goffart <ogoffart@woboq.com> ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -53,29 +54,47 @@ #include <QtCore/qglobal.h> #include <QtCore/qhash.h> +#include <QtCore/QWaitCondition> #ifndef QT_NO_THREAD QT_BEGIN_NAMESPACE -struct QReadWriteLockPrivate +class QReadWriteLockPrivate { - QReadWriteLockPrivate(QReadWriteLock::RecursionMode recursionMode) - : accessCount(0), waitingReaders(0), waitingWriters(0), - recursive(recursionMode == QReadWriteLock::Recursive), currentWriter(0) - { } +public: + QReadWriteLockPrivate(bool isRecursive = false) + : readerCount(0), writerCount(0), waitingReaders(0), waitingWriters(0), + recursive(isRecursive), id(0) {} QMutex mutex; - QWaitCondition readerWait; - QWaitCondition writerWait; - - int accessCount; + QWaitCondition writerCond; + QWaitCondition readerCond; + int readerCount; + int writerCount; int waitingReaders; int waitingWriters; - bool recursive; + + //Called with the mutex locked + bool lockForWrite(int timeout); + bool lockForRead(int timeout); + void unlock(); + + //memory management + int id; + void release(); + static QReadWriteLockPrivate *allocate(); + + // Recusive mutex handling Qt::HANDLE currentWriter; QHash<Qt::HANDLE, int> currentReaders; + + // called with the mutex unlocked + bool recursiveLockForWrite(int timeout); + bool recursiveLockForRead(int timeout); + void recursiveUnlock(); + }; QT_END_NAMESPACE |