Limit box art fetching to a single thread to improve UI responsiveness

This commit is contained in:
Cameron Gutman 2018-09-07 17:02:52 -07:00
parent f1d117d5d7
commit fae98eb13a
2 changed files with 5 additions and 2 deletions

View file

@ -6,8 +6,10 @@
BoxArtManager::BoxArtManager(QObject *parent) :
QObject(parent),
m_BoxArtDir(Path::getBoxArtCacheDir())
m_BoxArtDir(Path::getBoxArtCacheDir()),
m_ThreadPool(this)
{
m_ThreadPool.setMaxThreadCount(1);
if (!m_BoxArtDir.exists()) {
m_BoxArtDir.mkpath(".");
}
@ -41,7 +43,7 @@ QUrl BoxArtManager::loadBoxArt(NvComputer* computer, NvApp& app)
// If we get here, we need to fetch asynchronously.
// Kick off a worker on our thread pool to do just that.
NetworkBoxArtLoadTask* netLoadTask = new NetworkBoxArtLoadTask(this, computer, app);
QThreadPool::globalInstance()->start(netLoadTask);
m_ThreadPool.start(netLoadTask);
// Return the placeholder then we can notify the caller
// later when the real image is ready.

View file

@ -36,6 +36,7 @@ private:
getFilePathForBoxArt(NvComputer* computer, int appId);
QDir m_BoxArtDir;
QThreadPool m_ThreadPool;
};
class NetworkBoxArtLoadTask : public QObject, public QRunnable