summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread/qmutexpool.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/thread/qmutexpool.cpp')
-rw-r--r--src/corelib/thread/qmutexpool.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/corelib/thread/qmutexpool.cpp b/src/corelib/thread/qmutexpool.cpp
index 13e29c328a..144fa35137 100644
--- a/src/corelib/thread/qmutexpool.cpp
+++ b/src/corelib/thread/qmutexpool.cpp
@@ -123,22 +123,20 @@ QMutexPool *QMutexPool::instance()
return globalMutexPool();
}
-/*!
+/*! \fn QMutexPool::get(void *address)
Returns a QMutex from the pool. QMutexPool uses the value \a address
to determine which mutex is returned from the pool.
*/
-QMutex *QMutexPool::get(const void *address)
-{
- Q_ASSERT_X(address != 0, "QMutexPool::get()", "'address' argument cannot be zero");
- int index = int((quintptr(address) >> (sizeof(address) >> 1)) % mutexes.count());
-
- if (!mutexes[index]) {
- // mutex not created, create one
- QMutex *newMutex = new QMutex(recursionMode);
- if (!mutexes[index].testAndSetOrdered(0, newMutex))
- delete newMutex;
- }
+/*! \internal
+ create the mutex for the given index
+ */
+QMutex *QMutexPool::createMutex(int index)
+{
+ // mutex not created, create one
+ QMutex *newMutex = new QMutex(recursionMode);
+ if (!mutexes[index].testAndSetOrdered(0, newMutex))
+ delete newMutex;
return mutexes[index];
}