Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Backports:SLE-15-SP3:Update
attica-qt5.17058
0002-Ensure-categories.xml-is-only-fetched-once...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0002-Ensure-categories.xml-is-only-fetched-once-in-parall.patch of Package attica-qt5.17058
From 7851e94cb6ba7e0e3cfb4661eb525de6aa729472 Mon Sep 17 00:00:00 2001 From: Aleix Pol <aleixpol@kde.org> Date: Wed, 22 Sep 2021 16:19:39 +0200 Subject: [PATCH 2/2] Ensure categories.xml is only fetched once in parallel Otherwise we overload the server that is returning them fairly slowly anyway (2 to 3 seconds?). It seems like it serves these sequentially as well, which makes Discover startup stuttery. (cherry picked from commit 04bd6dcd39895ce3637145e719c3c427bc7f1ca1) --- src/atticabasejob.cpp | 7 +++---- src/provider.cpp | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/atticabasejob.cpp b/src/atticabasejob.cpp index 39b3a04..9ec965b 100644 --- a/src/atticabasejob.cpp +++ b/src/atticabasejob.cpp @@ -122,11 +122,10 @@ void BaseJob::dataFinished() void BaseJob::start() { - if (d->started) { - return; + if (!d->started) { + d->started = true; + QTimer::singleShot(0, this, &BaseJob::doWork); } - d->started = true; - QTimer::singleShot(0, this, &BaseJob::doWork); } void BaseJob::doWork() diff --git a/src/provider.cpp b/src/provider.cpp index 53495a3..3cbe8a9 100644 --- a/src/provider.cpp +++ b/src/provider.cpp @@ -63,6 +63,7 @@ #include <QDebug> #include <QUrlQuery> #include <QNetworkReply> +#include <QThreadStorage> #include <QFile> #include <QCoreApplication> @@ -1038,8 +1039,18 @@ ListJob<Category> *Provider::requestCategories() return nullptr; } - QUrl url = createUrl(QLatin1String("content/categories")); - ListJob<Category> *job = new ListJob<Category>(d->m_internals, createRequest(url)); + const QUrl url = createUrl(QLatin1String("content/categories")); + + // Thread-local cache of categories requests. They are fairly slow and block startup + static QThreadStorage<QHash<QUrl, ListJob<Category> *>> reqs; + ListJob<Category> *job = reqs.localData().value(url); + if (!job) { + job = new ListJob<Category>(d->m_internals, createRequest(url)); + QObject::connect(job, &BaseJob::finished, [url] { + reqs.localData().remove(url); + }); + reqs.localData().insert(url, job); + } return job; } -- 2.33.0
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor