diff options
author | Bradley T. Hughes <bradley.hughes@nokia.com> | 2009-05-22 09:01:39 (GMT) |
---|---|---|
committer | Bradley T. Hughes <bradley.hughes@nokia.com> | 2009-05-22 09:02:48 (GMT) |
commit | 31fcf8e77f8ef8020edfbfd224cf6e68cb0450bf (patch) | |
tree | 04f24d1ece2a316134e5b0c33b3e7866fdc3c52f | |
parent | 8502f76e820ab79181a1b8ac54c8431b298a2023 (diff) | |
download | Qt-31fcf8e77f8ef8020edfbfd224cf6e68cb0450bf.zip Qt-31fcf8e77f8ef8020edfbfd224cf6e68cb0450bf.tar.gz Qt-31fcf8e77f8ef8020edfbfd224cf6e68cb0450bf.tar.bz2 |
Update the QMutexPool API to be more like QMutex
If we ever decide to make this class public, the interfaces should be
similar.
-rw-r--r-- | src/corelib/thread/qmutexpool.cpp | 14 | ||||
-rw-r--r-- | src/corelib/thread/qmutexpool_p.h | 4 |
2 files changed, 9 insertions, 9 deletions
diff --git a/src/corelib/thread/qmutexpool.cpp b/src/corelib/thread/qmutexpool.cpp index 96a9940..77a3cca 100644 --- a/src/corelib/thread/qmutexpool.cpp +++ b/src/corelib/thread/qmutexpool.cpp @@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE // qt_global_mutexpool is here for backwards compatability only, // use QMutexpool::instance() in new clode. Q_CORE_EXPORT QMutexPool *qt_global_mutexpool = 0; -Q_GLOBAL_STATIC_WITH_ARGS(QMutexPool, globalMutexPool, (true)) +Q_GLOBAL_STATIC_WITH_ARGS(QMutexPool, globalMutexPool, (QMutex::Recursive)) /*! \class QMutexPool @@ -88,15 +88,15 @@ Q_GLOBAL_STATIC_WITH_ARGS(QMutexPool, globalMutexPool, (true)) */ /*! - Constructs a QMutexPool, reserving space for \a size QMutexes. If - \a recursive is true, all QMutexes in the pool will be recursive - mutexes; otherwise they will all be non-recursive (the default). + Constructs a QMutexPool, reserving space for \a size QMutexes. All + mutexes in the pool are created with \a recursionMode. By default, + all mutexes are non-recursive. The QMutexes are created when needed, and deleted when the QMutexPool is destructed. */ -QMutexPool::QMutexPool(bool recursive, int size) - : mutexes(size), count(size), recurs(recursive) +QMutexPool::QMutexPool(QMutex::RecursionMode recursionMode, int size) + : mutexes(size), count(size), recursionMode(recursionMode) { for (int index = 0; index < count; ++index) { mutexes[index] = 0; @@ -134,7 +134,7 @@ QMutex *QMutexPool::get(const void *address) if (!mutexes[index]) { // mutex not created, create one - QMutex *newMutex = new QMutex(recurs ? QMutex::Recursive : QMutex::NonRecursive); + QMutex *newMutex = new QMutex(recursionMode); if (!mutexes[index].testAndSetOrdered(0, newMutex)) delete newMutex; } diff --git a/src/corelib/thread/qmutexpool_p.h b/src/corelib/thread/qmutexpool_p.h index 1009ebb..4c1e32c 100644 --- a/src/corelib/thread/qmutexpool_p.h +++ b/src/corelib/thread/qmutexpool_p.h @@ -64,7 +64,7 @@ QT_BEGIN_NAMESPACE class Q_CORE_EXPORT QMutexPool { public: - explicit QMutexPool(bool recursive = false, int size = 128); + explicit QMutexPool(QMutex::RecursionMode recursionMode = QMutex::NonRecursive, int size = 128); ~QMutexPool(); QMutex *get(const void *address); @@ -74,7 +74,7 @@ public: private: QVarLengthArray<QAtomicPointer<QMutex>, 128> mutexes; int count; - bool recurs; + QMutex::RecursionMode recursionMode; }; extern Q_CORE_EXPORT QMutexPool *qt_global_mutexpool; |