summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <[email protected]>2025-03-23 17:12:23 +0100
committerQt Cherry-pick Bot <[email protected]>2025-06-27 20:11:12 +0000
commit72968bb6bd179382629172383d3ac0832f6251fc (patch)
treec161c725c66a2565c76c13852c8f4eae272bc7e8
parentc75d68376950cae1f5c97013677e38d2792d0c06 (diff)
QFactoryLoader: drop libraries mutex sooner
Both QFactoryLoader::metaDataKeys() and QFactoryLoader::metaData() locked the mutex under QT_CONFIG(library) near the start of the function and never dropped it until the end of the function. This is not necessary and, by Amdahl's Law, reduces concurrency. Drop the mutex before the #endif again. This isn't as good as splitting the metaDataKeys() loop into one that extracts the QPluginParsedMetaDatas, dropping the mutex, and then another doing the JSON work, but it's better than the status quo and the best the maintainer will accept. Amends 878e3342e1c9bd8a4da6a2e9e1508dacbe0c7ab6. Change-Id: Ie69d4a2d20ac02c4331ffcc3f1281caf7cbeb6fe Reviewed-by: Thiago Macieira <[email protected]> (cherry picked from commit f987e2bcb2be5959b1f80999bfe910d80c80a740) Reviewed-by: Qt Cherry-pick Bot <[email protected]> (cherry picked from commit d5f1bf0cbc9f3b2c6c49cd7e82965630a1bc80f9)
-rw-r--r--src/corelib/plugin/qfactoryloader.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp
index 1c6ebdaea39..29702013b9e 100644
--- a/src/corelib/plugin/qfactoryloader.cpp
+++ b/src/corelib/plugin/qfactoryloader.cpp
@@ -507,6 +507,7 @@ QFactoryLoader::MetaDataList QFactoryLoader::metaData() const
QMutexLocker locker(&d->mutex);
for (const auto &library : d->libraries)
metaData.append(library->metaData);
+ locker.unlock();
#endif
QLatin1StringView iid(d->iid.constData(), d->iid.size());
@@ -534,6 +535,7 @@ QList<QCborArray> QFactoryLoader::metaDataKeys() const
const QCborValue md = library->metaData.value(QtPluginMetaDataKeys::MetaData);
metaData.append(md["Keys"_L1].toArray());
}
+ locker.unlock();
#endif
QLatin1StringView iid(d->iid.constData(), d->iid.size());