summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2012-08-03 11:40:35 +0200
committerQt by Nokia <qt-info@nokia.com>2012-08-04 00:52:14 +0200
commit4e542d958a8fa81c91e55c1358e15c84e34d15de (patch)
tree0dae9c119fad275a0f3a062b1b3920edf1eda77d /src/corelib
parent0715e1e6c2d38776cd9d5661639ce517f685fa6f (diff)
ICU: Mark which functions are threadsafe and which ones aren't
Mark the thread-safe functions with the \threadsafe doc marker. This includes public API, which should be thread-safe anyway. The thread-unsafe functions are marked "\nonreentrant" already. In addition, I renamed the functions that must be called with locked mutexes to Unlocked, following the convention in other libraries like libdbus-1. Change-Id: Ibd93d1266149767f546c8e82959b73c138008469 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/codecs/qicucodec.cpp15
-rw-r--r--src/corelib/codecs/qicucodec_p.h6
-rw-r--r--src/corelib/codecs/qtextcodec.cpp13
3 files changed, 20 insertions, 14 deletions
diff --git a/src/corelib/codecs/qicucodec.cpp b/src/corelib/codecs/qicucodec.cpp
index 221d130321..b591a3d50d 100644
--- a/src/corelib/codecs/qicucodec.cpp
+++ b/src/corelib/codecs/qicucodec.cpp
@@ -52,8 +52,6 @@
QT_BEGIN_NAMESPACE
-extern QMutex *qTextCodecsMutex();
-
static void qIcuCodecStateFree(QTextCodec::ConverterState *state)
{
ucnv_close(static_cast<UConverter *>(state->d));
@@ -376,7 +374,7 @@ static QTextCodec *loadQtCodec(const char *name)
return 0;
}
-
+/// \threadsafe
QList<QByteArray> QIcuCodec::availableCodecs()
{
QList<QByteArray> codecs;
@@ -412,6 +410,7 @@ QList<QByteArray> QIcuCodec::availableCodecs()
return codecs;
}
+/// \threadsafe
QList<int> QIcuCodec::availableMibs()
{
QList<int> mibs;
@@ -424,7 +423,7 @@ QList<int> QIcuCodec::availableMibs()
return mibs;
}
-QTextCodec *QIcuCodec::defaultCodec()
+QTextCodec *QIcuCodec::defaultCodecUnlocked()
{
QCoreGlobalData *globalData = QCoreGlobalData::instance();
if (!globalData)
@@ -438,13 +437,13 @@ QTextCodec *QIcuCodec::defaultCodec()
#else
const char *name = ucnv_getDefaultName();
#endif
- c = codecForName(name);
+ c = codecForNameUnlocked(name);
globalData->codecForLocale.storeRelease(c);
return c;
}
-QTextCodec *QIcuCodec::codecForName(const char *name)
+QTextCodec *QIcuCodec::codecForNameUnlocked(const char *name)
{
// backwards compatibility with Qt 4.x
if (!qstrcmp(name, "CP949"))
@@ -525,11 +524,11 @@ QTextCodec *QIcuCodec::codecForName(const char *name)
}
-QTextCodec *QIcuCodec::codecForMib(int mib)
+QTextCodec *QIcuCodec::codecForMibUnlocked(int mib)
{
for (int i = 0; i < mibToNameSize; ++i) {
if (mibToName[i].mib == mib)
- return codecForName(mibToNameTable + mibToName[i].index);
+ return codecForNameUnlocked(mibToNameTable + mibToName[i].index);
}
return 0;
}
diff --git a/src/corelib/codecs/qicucodec_p.h b/src/corelib/codecs/qicucodec_p.h
index 0a8ac7d996..2d3f21481d 100644
--- a/src/corelib/codecs/qicucodec_p.h
+++ b/src/corelib/codecs/qicucodec_p.h
@@ -67,10 +67,10 @@ public:
static QList<QByteArray> availableCodecs();
static QList<int> availableMibs();
- static QTextCodec *defaultCodec();
+ static QTextCodec *defaultCodecUnlocked();
- static QTextCodec *codecForName(const char *name);
- static QTextCodec *codecForMib(int mib);
+ static QTextCodec *codecForNameUnlocked(const char *name);
+ static QTextCodec *codecForMibUnlocked(int mib);
QString convertToUnicode(const char *, int, ConverterState *) const;
QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const;
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
index 349ff0fbd1..35a430cf65 100644
--- a/src/corelib/codecs/qtextcodec.cpp
+++ b/src/corelib/codecs/qtextcodec.cpp
@@ -146,6 +146,7 @@ static QTextCodec *checkForCodec(const QByteArray &name) {
static void setup();
+// \threadsafe
// this returns the codec the method sets up as locale codec to
// avoid a race condition in codecForLocale() when
// setCodecForLocale(0) is called at the same time.
@@ -495,6 +496,7 @@ QTextCodec::~QTextCodec()
*/
/*!
+ \threadsafe
Searches all installed QTextCodec objects and returns the one
which best matches \a name; the match is case-insensitive. Returns
0 if no codec matching the name \a name could be found.
@@ -538,12 +540,13 @@ QTextCodec *QTextCodec::codecForName(const QByteArray &name)
return 0;
#else
- return QIcuCodec::codecForName(name);
+ return QIcuCodec::codecForNameUnlocked(name);
#endif
}
/*!
+ \threadsafe
Returns the QTextCodec which matches the
\l{QTextCodec::mibEnum()}{MIBenum} \a mib.
*/
@@ -578,13 +581,14 @@ QTextCodec* QTextCodec::codecForMib(int mib)
}
#ifdef QT_USE_ICU
- return QIcuCodec::codecForMib(mib);
+ return QIcuCodec::codecForMibUnlocked(mib);
#endif
return 0;
}
/*!
+ \threadsafe
Returns the list of all available codecs, by name. Call
QTextCodec::codecForName() to obtain the QTextCodec for the name.
@@ -616,6 +620,7 @@ QList<QByteArray> QTextCodec::availableCodecs()
}
/*!
+ \threadsafe
Returns the list of MIBs for all available codecs. Call
QTextCodec::codecForMib() to obtain the QTextCodec for the MIB.
@@ -659,6 +664,7 @@ void QTextCodec::setCodecForLocale(QTextCodec *c)
}
/*!
+ \threadsafe
Returns a pointer to the codec most suitable for this locale.
On Windows, the codec will be based on a system locale. On Unix
@@ -677,8 +683,9 @@ QTextCodec* QTextCodec::codecForLocale()
QTextCodec *codec = globalData->codecForLocale.loadAcquire();
if (!codec) {
#ifdef QT_USE_ICU
- codec = QIcuCodec::defaultCodec();
+ codec = QIcuCodec::defaultCodecUnlocked();
#else
+ // setupLocaleMapper locks as necessary
codec = setupLocaleMapper();
#endif
}