diff options
Diffstat (limited to 'src/corelib/thread')
-rw-r--r-- | src/corelib/thread/qreadwritelock.cpp | 57 | ||||
-rw-r--r-- | src/corelib/thread/qreadwritelock_p.h | 1 | ||||
-rw-r--r-- | src/corelib/thread/qthread.h | 12 | ||||
-rw-r--r-- | src/corelib/thread/qthread_unix.cpp | 2 |
4 files changed, 3 insertions, 69 deletions
diff --git a/src/corelib/thread/qreadwritelock.cpp b/src/corelib/thread/qreadwritelock.cpp index 0ea8c4c00f..e6477bf5e0 100644 --- a/src/corelib/thread/qreadwritelock.cpp +++ b/src/corelib/thread/qreadwritelock.cpp @@ -136,27 +136,11 @@ void QReadWriteLock::lockForRead() { QMutexLocker lock(&d->mutex); - Qt::HANDLE self = 0; - if (d->recursive) { - self = QThread::currentThreadId(); - - QHash<Qt::HANDLE, int>::iterator it = d->currentReaders.find(self); - if (it != d->currentReaders.end()) { - ++it.value(); - ++d->accessCount; - Q_ASSERT_X(d->accessCount > 0, "QReadWriteLock::lockForRead()", - "Overflow in lock counter"); - return; - } - } - while (d->accessCount < 0 || d->waitingWriters) { ++d->waitingReaders; d->readerWait.wait(&d->mutex); --d->waitingReaders; } - if (d->recursive) - d->currentReaders.insert(self, 1); ++d->accessCount; Q_ASSERT_X(d->accessCount > 0, "QReadWriteLock::lockForRead()", "Overflow in lock counter"); @@ -182,24 +166,8 @@ bool QReadWriteLock::tryLockForRead() { QMutexLocker lock(&d->mutex); - Qt::HANDLE self = 0; - if (d->recursive) { - self = QThread::currentThreadId(); - - QHash<Qt::HANDLE, int>::iterator it = d->currentReaders.find(self); - if (it != d->currentReaders.end()) { - ++it.value(); - ++d->accessCount; - Q_ASSERT_X(d->accessCount > 0, "QReadWriteLock::tryLockForRead()", - "Overflow in lock counter"); - return true; - } - } - if (d->accessCount < 0) return false; - if (d->recursive) - d->currentReaders.insert(self, 1); ++d->accessCount; Q_ASSERT_X(d->accessCount > 0, "QReadWriteLock::tryLockForRead()", "Overflow in lock counter"); @@ -230,20 +198,6 @@ bool QReadWriteLock::tryLockForRead(int timeout) { QMutexLocker lock(&d->mutex); - Qt::HANDLE self = 0; - if (d->recursive) { - self = QThread::currentThreadId(); - - QHash<Qt::HANDLE, int>::iterator it = d->currentReaders.find(self); - if (it != d->currentReaders.end()) { - ++it.value(); - ++d->accessCount; - Q_ASSERT_X(d->accessCount > 0, "QReadWriteLock::tryLockForRead()", - "Overflow in lock counter"); - return true; - } - } - while (d->accessCount < 0 || d->waitingWriters) { ++d->waitingReaders; bool success = d->readerWait.wait(&d->mutex, timeout < 0 ? ULONG_MAX : ulong(timeout)); @@ -251,8 +205,6 @@ bool QReadWriteLock::tryLockForRead(int timeout) if (!success) return false; } - if (d->recursive) - d->currentReaders.insert(self, 1); ++d->accessCount; Q_ASSERT_X(d->accessCount > 0, "QReadWriteLock::tryLockForRead()", "Overflow in lock counter"); @@ -412,15 +364,6 @@ void QReadWriteLock::unlock() bool unlocked = false; if (d->accessCount > 0) { // releasing a read lock - if (d->recursive) { - Qt::HANDLE self = QThread::currentThreadId(); - QHash<Qt::HANDLE, int>::iterator it = d->currentReaders.find(self); - if (it != d->currentReaders.end()) { - if (--it.value() <= 0) - d->currentReaders.erase(it); - } - } - unlocked = --d->accessCount == 0; } else if (d->accessCount < 0 && ++d->accessCount == 0) { // released a write lock diff --git a/src/corelib/thread/qreadwritelock_p.h b/src/corelib/thread/qreadwritelock_p.h index e57c0e403f..15a6d1f57e 100644 --- a/src/corelib/thread/qreadwritelock_p.h +++ b/src/corelib/thread/qreadwritelock_p.h @@ -69,7 +69,6 @@ struct QReadWriteLockPrivate bool recursive; Qt::HANDLE currentWriter; - QHash<Qt::HANDLE, int> currentReaders; }; QT_END_NAMESPACE diff --git a/src/corelib/thread/qthread.h b/src/corelib/thread/qthread.h index 58755b9625..bfc469583d 100644 --- a/src/corelib/thread/qthread.h +++ b/src/corelib/thread/qthread.h @@ -106,16 +106,8 @@ public: static void usleep(unsigned long); Q_SIGNALS: - void started( -#if !defined(Q_QDOC) - QPrivateSignal -#endif - ); - void finished( -#if !defined(Q_QDOC) - QPrivateSignal -#endif - ); + void started(QPrivateSignal); + void finished(QPrivateSignal); protected: virtual void run(); diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index 996ed1779d..77093c9cf1 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -400,7 +400,7 @@ int QThread::idealThreadCount() Q_DECL_NOTHROW cores = (int)psd.psd_proc_cnt; } #elif defined(Q_OS_BSD4) - // FreeBSD, OpenBSD, NetBSD, BSD/OS, Mac OS X + // FreeBSD, OpenBSD, NetBSD, BSD/OS, OS X, iOS size_t len = sizeof(cores); int mib[2]; mib[0] = CTL_HW; |