summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread
diff options
context:
space:
mode:
authormread <qt-info@nokia.com>2011-02-17 11:05:36 (GMT)
committermread <qt-info@nokia.com>2011-03-09 12:47:01 (GMT)
commita84dcc30b096915dc71d8c9696696731dee45c48 (patch)
tree3f395856b6bda9b9120bfa8eb897917dc41a77a5 /src/corelib/thread
parent3d84f558a80b0c224b6c36808fd8f1fee8ace752 (diff)
downloadQt-a84dcc30b096915dc71d8c9696696731dee45c48.zip
Qt-a84dcc30b096915dc71d8c9696696731dee45c48.tar.gz
Qt-a84dcc30b096915dc71d8c9696696731dee45c48.tar.bz2
QMutex symbian review changes
Improved documentation Added a trywait(0) test and fixed the bug it found Symbian implementation throws on construction fail Task-number: QTBUG-13990 Reviewed-by: Shane Kearns
Diffstat (limited to 'src/corelib/thread')
-rw-r--r--src/corelib/thread/qmutex_p.h3
-rw-r--r--src/corelib/thread/qmutex_symbian.cpp4
2 files changed, 6 insertions, 1 deletions
diff --git a/src/corelib/thread/qmutex_p.h b/src/corelib/thread/qmutex_p.h
index c213c80..2588228 100644
--- a/src/corelib/thread/qmutex_p.h
+++ b/src/corelib/thread/qmutex_p.h
@@ -98,8 +98,11 @@ public:
HANDLE event;
#elif defined(Q_OS_SYMBIAN)
# ifdef QT_SYMBIAN_USE_RFASTLOCK
+ // RFastLock is a fast semaphone which only calls into the kernel side if there is contention
RFastLock lock;
# else
+ // RSemaphore is used on Symbian OS versions that do not have a timed RFastLock wait.
+ // There is no timed wait on RMutex itself, so RSemaphore has to be used instead.
RSemaphore lock;
# endif
#endif
diff --git a/src/corelib/thread/qmutex_symbian.cpp b/src/corelib/thread/qmutex_symbian.cpp
index e7487cd..09c59af 100644
--- a/src/corelib/thread/qmutex_symbian.cpp
+++ b/src/corelib/thread/qmutex_symbian.cpp
@@ -62,6 +62,7 @@ QMutexPrivate::QMutexPrivate(QMutex::RecursionMode mode)
#endif
if (r != KErrNone)
qWarning("QMutex: failed to create lock, error %d", r);
+ qt_symbian_throwIfError(r);
}
QMutexPrivate::~QMutexPrivate()
@@ -86,7 +87,8 @@ bool QMutexPrivate::wait(int timeout)
do {
int waitTime = qMin(KMaxTInt / 1000, timeout);
timeout -= waitTime;
- r = lock.Wait(waitTime * 1000);
+ // Symbian undocumented feature - 0us means no timeout! Use a minimum of 1
+ r = lock.Wait(qMax(1, waitTime * 1000));
} while (r != KErrNone && r != KErrGeneral && r != KErrArgument && timeout > 0);
}
bool returnValue = (r == KErrNone);