summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread/qmutex.h
Commit message (Collapse)AuthorAgeFilesLines
* Add a comment stating QMutex::isRecursive should be made const in Qt6Olivier Goffart2014-06-261-1/+1
| | | | | Change-Id: I452b0764790112c59af77bc8d95f403ff37cbc4a Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* Fix QMutex documentation saying some function are static while they are notOlivier Goffart2014-06-261-7/+7
| | | | | | | | | | | | | qdoc only see a fake QMutex class (the same as the one built in bootstrap) But that fake QMutex had static member while the normal QMutex class has non static member. QMutexLocker::mutex is also a const function in the real QMutexLocker Task-number: QTBUG-38522 Change-Id: I220434ffc6a9e990029f770e2536ecb55b4e2182 Reviewed-by: Martin Smith <martin.smith@digia.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* Use the new 3-operand testAndSet functions in QMutexThiago Macieira2014-04-051-0/+6
| | | | | | | | | This allows us to get the current value of the QMutex / QBasicMutex after the testAndSet operation failed. It saves an extra load from memory. Change-Id: I4922a8b3df15e342b177b13f56cf4f1184314520 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Remove QT_{BEGIN,END}_HEADER macro usageSergio Ahumada2013-01-291-4/+0
| | | | | | | | | | | The macro was made empty in ba3dc5f3b56d1fab6fe37fe7ae08096d7dc68bcb and is no longer necessary or used. Discussed-on: http://lists.qt-project.org/pipermail/development/2013-January/009284.html Change-Id: Id2bb2e2cabde059305d4af5f12593344ba30f001 Reviewed-by: Laszlo Papp <lpapp@kde.org> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com> Reviewed-by: hjk <hjk121@nokiamail.com>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Replace macro qdoc with Q_QDOCDebao Zhang2013-01-081-3/+3
| | | | | | | | Both qdoc and Q_QDOC are used in source code, which looks not good. Change-Id: I4f3a71670278b0758d92bfa5db086a07e1b1acfd Reviewed-by: hjk <qthjk@ovi.com> Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-221-24/+24
| | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: If1cc974286d29fd01ec6c19dd4719a67f4c3f00e Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* Remove QBasicAtomic::tryLock with a timerThiago Macieira2012-09-141-2/+2
| | | | | | | | | | The non-futex implementation does not support timed locks in QBasicMutex. That is only supported in QMutex (due to the destructor). Change-Id: I46d33a66a36e05c8a4344823537178e80a6ddd76 Reviewed-by: Qt Doc Bot <qt_docbot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Split the timed mutex lock from the non-timed lock functionsThiago Macieira2012-09-141-1/+2
| | | | | | | | | Non-timed mutex locks are by far more common, so let's try not to penalise the locking of those with code that won't get used that often. Change-Id: I37f56d6429836467fdec2e588c0fb22d914b5d75 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Make QBasicMutex be exclusively non-recursiveThiago Macieira2012-09-141-1/+5
| | | | | | | | | | | | | | | Dispatch to the recursive mutex functions from QMutex::lock, tryLock and unlock. This has the benefit that those using QBasicMutex will not go through the testing for recursive mutexes. It simplifies a little the code for those users. For the users of QMutex, the code required to perform a lock does not appear to change. Change-Id: I0ca9965e012b283c30f1fab8e9f6d9b3288c2247 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Mark mutex locking and unlocking functions with noexceptThiago Macieira2012-08-251-14/+18
| | | | | | | | | | | | | | | | | | | | | Unlocking a mutex can never throw an exception. That doesn't make sense and our code should make sure it can't happen. Right now, provided that the system-level functions don't throw, we don't either. Locking a mutex cannot throw on Linux because we use futexes directly. A non-recursive mutex is just a futex, whereas a recursive mutex uses a mutex (a futex) to manage a lock count. However, on other platforms, due to the freelist, there can be memory allocation, which means it might throw std::bad_alloc. Not because of the freelist itself (that uses malloc and will just crash if malloc fails) but because of Q_GLOBAL_STATIC. In 5.1, the global static will be noexcept provided the type's constructor is so too (it is, in this case). Change-Id: I4c562383f48de1be7827b9afb512d73eaf0792d5 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Optimise QMutexLocker a little: don't call relock() in the constructorThiago Macieira2012-08-061-2/+5
| | | | | | | | | | | | QMutexLocker does not support being passed already-locked mutexes, unless they are recursive mutexes. But in that case, it behaves as if the mutex weren't locked in the first place. Since that's the case, there's no point in testing the low bit to see if it's set or not. It's never going to be. Change-Id: Ie4b81f7e2cca16e6db36f3cb51a5377dbdfc157d Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* QMutex: de-inline lock(), unlock(), and tryLock()Bradley T. Hughes2012-05-291-6/+11
| | | | | | | | | | | | | | See the discussion of this topic on the mailing list: http://lists.qt-project.org/pipermail/development/2012-May/003943.html The consensus is to not have these methods have inline code to actually acquire the lock (i.e. no atomic test-and-set or similar). QBasicMutex is unchanged, and continues to have inlined lock(), tryLock(), and unlock(). QMutexLocker has been changed to always call QMutex::lock() (even though the constructor takes a QBasicMutex parameter). Change-Id: Ic7d2d9d581e6b254c84fdfdd8ce6c425535a8078 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: Prepare for building modular QtCore docs.Casper van Donderen2012-04-191-1/+0
| | | | | | | | | | | | This change fixes most qdoc errors in QtCore. There are about 900 left. The main thing this change does is moving documentation from qtcore from /doc/src to /src/corelib/doc. Other issues resolved are mis-use of qdoc commands. Change-Id: I002d01edfb13575e8bf27ce91596a577a92562d1 Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com> Reviewed-by: Jerome Pasion <jerome.pasion@nokia.com>
* Remove "All rights reserved" line from license headers.Jason McDonald2012-01-301-1/+1
| | | | | | | | | | As in the past, to avoid rewriting various autotests that contain line-number information, an extra blank line has been inserted at the end of the license text to ensure that this commit does not change the total number of lines in the license header. Change-Id: I311e001373776812699d6efc045b5f742890c689 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Remove use of QT_MODULE from libraryGunnar Sletta2012-01-251-1/+0
| | | | | | | | | | These defines were there to aid in the commercial licensing scheme we used long ago, and are no longer needed. Keep a QT_MODULE(x) define so other modules continue compiling. Change-Id: I8fd76cd5270df8f14aee746b6cf32ebf7c23fec7 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Update contact information in license headers.Jason McDonald2012-01-231-1/+1
| | | | | | | Replace Nokia contact email address with Qt Project website. Change-Id: I431bbbf76d7c27d8b502f87947675c116994c415 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update copyright year in license headers.Jason McDonald2012-01-051-1/+1
| | | | | Change-Id: I02f2c620296fcd91d4967d58767ea33fc4e1e7dc Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* QRecursiveMutexPrivate should not inherit from QMutexPrivateOlivier Goffart2011-10-311-5/+5
| | | | | | | | QMutexPrivate takes more memory than necessary, and also initialize platform specific ressources. Change-Id: I70be1b89b1c21499645785ae47693a6b2514e28b Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
* Rename QBasicMutex::d to QBasicMutex::d_ptrOlivier Goffart2011-10-311-4/+4
| | | | | | | | | Because we use d as a local variable. We used this->d to refer it, but this can be confusing to have twice the same name Change-Id: I570aa5f444ada358eb456d6b3d9b8bfa60b10bbf Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
* Make all uses of QBasicAtomicInt and Pointer use load() and store()Thiago Macieira2011-10-031-1/+1
| | | | | | | | | | | | | | Most of these changes are search-and-replace of d->ref ==, d->ref != and d->ref =. The QBasicAtomicPointer in QObjectPrivate::Connection didn't need to be basic, so I made it QAtomicPointer. Change-Id: Ie3271abd1728af599f9ab17c6f4868e475f17bb6 Reviewed-on: http://codereview.qt-project.org/5030 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* QMutex is now just a pointerOlivier Goffart2011-07-291-75/+46
| | | | | | | | | | | | | | | | | | | | | | | | | And added a POD QBasicMutex. (QBasicMutex* can safely be static_cast'ed to QMutex*) The d pointer is not anymore always a QMutexPrivate. If d == 0x0: the mutex is unlocked If d == 0x1: the mutex is locked, uncontended On linux: if d == 0x3: the mutex is locked contended, waiting on a futex If d is a pointer, it is a recursive mutex. On non-linux platforms: When a thread tries to lock a mutex for which d == 0x1, it will try to assing it a QMutexPrivated (allocated from a freelist) in order to wait for it. Change-Id: Ie1431cd9402a576fdd9a693cfd747166eebf5622 Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com> Reviewed-on: http://codereview.qt.nokia.com/2116 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Olivier Goffart <olivier.goffart@nokia.com>
* Remove the remaining QT3_SUPPORT code in corelibLars Knoll2011-06-291-18/+0
| | | | | | | Change-Id: I6641c62d75d2034a46ea7cc869ae65285ae8b8f4 Reviewed-on: http://codereview.qt.nokia.com/866 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Liang Qi <liang.qi@nokia.com>
* Update licenseheader text in source files for qtbase Qt moduleJyri Tahtela2011-05-241-17/+17
| | | | | | | Updated version of LGPL and FDL licenseheaders. Apply release phase licenseheaders for all source files. Reviewed-by: Trust Me
* Initial import from the monolithic Qt.Qt by Nokia2011-04-271-0/+248
This is the beginning of revision history for this module. If you want to look at revision history older than this, please refer to the Qt Git wiki for how to use Git history grafting. At the time of writing, this wiki is located here: http://qt.gitorious.org/qt/pages/GitIntroductionWithQt If you have already performed the grafting and you don't see any history beyond this commit, try running "git log" with the "--follow" argument. Branched from the monolithic repo, Qt master branch, at commit 896db169ea224deb96c59ce8af800d019de63f12