summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread/qthreadstorage.cpp
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@woboq.com>2012-01-29 20:32:22 +0100
committerQt by Nokia <qt-info@nokia.com>2012-02-01 22:23:55 +0100
commitb69bb01f11f5104d8e807c7a2bdc92d3ffa394b4 (patch)
tree1f363f3922a4e51287bd0e6eac1b1f14ff2ba3b1 /src/corelib/thread/qthreadstorage.cpp
parentc094891db377d750c0e8290b98971b69161a0552 (diff)
Use QBasicMutex instead of Q_GLOBAL_STATIC QMutex
QBasicMutex is a POD and can be used as a static global object. in qpicture.cpp factoryLoader is used only once, and under the mutex, so there is no need for Q_GLOBAL_STATIC for it, it can be a function static in qhostinfo_unix.cpp the code seemed wrong while compiled with namespace and QT_NO_GETADDRINFO. I also could get rid of one include because it was included earlier. Change-Id: I3c700203c3e067266c20733f4bda8031446dbb86 Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
Diffstat (limited to 'src/corelib/thread/qthreadstorage.cpp')
-rw-r--r--src/corelib/thread/qthreadstorage.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/corelib/thread/qthreadstorage.cpp b/src/corelib/thread/qthreadstorage.cpp
index 43a8056c33..1dfa3305bc 100644
--- a/src/corelib/thread/qthreadstorage.cpp
+++ b/src/corelib/thread/qthreadstorage.cpp
@@ -71,13 +71,13 @@ void qtsDebug(const char *fmt, ...)
# define DEBUG_MSG if(false)qDebug
#endif
-Q_GLOBAL_STATIC(QMutex, mutex)
+static QBasicMutex destructorsMutex;
typedef QVector<void (*)(void *)> DestructorMap;
Q_GLOBAL_STATIC(DestructorMap, destructors)
QThreadStorageData::QThreadStorageData(void (*func)(void *))
{
- QMutexLocker locker(mutex());
+ QMutexLocker locker(&destructorsMutex);
DestructorMap *destr = destructors();
if (!destr) {
/*
@@ -109,7 +109,7 @@ QThreadStorageData::QThreadStorageData(void (*func)(void *))
QThreadStorageData::~QThreadStorageData()
{
DEBUG_MSG("QThreadStorageData: Released id %d", id);
- QMutexLocker locker(mutex());
+ QMutexLocker locker(&destructorsMutex);
if (destructors())
(*destructors())[id] = 0;
}
@@ -153,7 +153,7 @@ void **QThreadStorageData::set(void *p)
value,
data->thread);
- QMutexLocker locker(mutex());
+ QMutexLocker locker(&destructorsMutex);
DestructorMap *destr = destructors();
void (*destructor)(void *) = destr ? destr->value(id) : 0;
locker.unlock();
@@ -174,7 +174,7 @@ void **QThreadStorageData::set(void *p)
void QThreadStorageData::finish(void **p)
{
QVector<void *> *tls = reinterpret_cast<QVector<void *> *>(p);
- if (!tls || tls->isEmpty() || !mutex())
+ if (!tls || tls->isEmpty() || !destructors())
return; // nothing to do
DEBUG_MSG("QThreadStorageData: Destroying storage for thread %p", QThread::currentThread());
@@ -190,7 +190,7 @@ void QThreadStorageData::finish(void **p)
continue;
}
- QMutexLocker locker(mutex());
+ QMutexLocker locker(&destructorsMutex);
void (*destructor)(void *) = destructors()->value(i);
locker.unlock();